samedi 28 février 2015

Zend ajax form + first time populate


Vote count:

0




in my document/detail i have table with some users and on each row i have link to edit this user (form oppened in twitter bootstrap modal). In form submit i have parametr 'onclick' => 'return submitForm();' where submitForm() is an ajax action to resend data back to controller to dynamic zend validation. Problem is when I want to populate to edit form right users data after I open form in modal for first time. Probably i can do it by jquery so when i click on modal open link it will take data from table row and fill form elements...but here is problem that in table row I usually dont have all users data (minimalistic table) so i cannot populate all form elements.


controller:



public function detaillAction() {
$id = $this->_getParam("id", 0); //document id
$document = new Application_Model_DbTable_Document();
$doc = $document->findById($id);
//..and some another models

$this->view->headScript()->appendFile($this->view->baseUrl('/js/document-edit_user.js'));
$form_edit_users = new Application_Form_EditUsers();
if ($this->_request->isXmlHttpRequest()) {
if ($this->getRequest()->isPost()) {
$formData = $this->getRequest()->getPost();
//send json error messages here
}
}
else{
//First time populate form
$users = new Application_Model_DbTable_Users();
$user = $users->findById($user_id); //where to get this id?
$form_edit_users->populate($user);
$this->view->form_edit_users = $form_edit_users;
}
}


So what is best way how to get user_id for first time form render to this controller? Thx



asked 1 min ago







Zend ajax form + first time populate

Aucun commentaire:

Enregistrer un commentaire