Hi,
I have a form which have elements that has the belongsTo attribute. My
problem is when $form->populate($this->_request->getPost()); is called those
belongsTo elements are not populated. Here is some code:
class TryController extends Zend_Controller_Action {
function indexAction() {
$form = new TryForm();
if ($this->_request->isPost()) {
$this->view->info = "TRUE";
$form->populate($this->_request->getPost());
}
$this->view->form = $form;
$this->view->style = $form->formStyle;
}
}
class TryForm extends Zend_Form{
public $formStyle;
public function init() {
$this->addElement('text','parentFieldOne');
$this->addElement('text','parentFieldTwo');
// $this->useSubForm();
$this->useBelongsTo();
$this->addElement('submit', 'submit', array('label' => 'Submit'));
}
private function useSubForm() {
$childForm = new Zend_Form_SubForm();
$childForm->addElement('text', 'childFieldOne');
$childForm->addElement('text', 'childFieldTwo');
$this->addSubForm($childForm, 'childForm');
$this->formStyle = 'Sub Form';
}
private function useBelongsTo(){
$this->addElement('text', 'childFieldOne', array('belongsTo' =>
'childForm'));
$this->addElement('text', 'childFieldTwo', array('belongsTo' =>
'childForm'));
$this->formStyle = 'BelongsTo';
}
}
When calling $this->useBelongsTo(); the child fields are not populated
When calling $this->useSubForm();. the child fields are populated.
However, I don't want to use a subform because in my real code I have a need
that the child elements are not physically located together on the page.
Thanks.
--
View this message in context:
http://www.nabble.com/Populating-form-that-has-belongTo-elements-tp23727030p23727030.html
Sent from the Zend Framework mailing list archive at Nabble.com.