Hi I am making a sub form in zend with the following code:
class Admin_Form_StudentAdmission extends Zend_Form
{
public function init()
{
$this->setMethod('post');
$personalDetailsForm = new Zend_Form_SubForm();
$personalDetailsForm->setIsArray(true);
$student_first_name = $this->CreateElement('text','first_name')
->setAttribs(array('placeholder'=>'First Name', 'mendatory'=>'true'))
->setRequired(true)
->addValidators(array(
array('NotEmpty', true, array('messages' => 'Please enter First Name')),
array('stringLength',true,array(2, 10, 'messages'=> 'First Name should be 2 to 10 characters long.')),
))
->addFilter(new Zend_Filter_StringTrim())
->setDecorators(array( array('ViewHelper')
));
$personalDetailsForm->addElement($student_first_name);
$this->addSubForm($personalDetailsForm, 'student_personal_details');
}
}
And now I am rendering this form with below php code:
$personalDetailsForm = $this->form->getSubForm('student_personal_details');
echo $personalDetailsForm->first_name;
But this renders the element as
<input type="text" mendatory="true" placeholder="First Name" value="" id="first_name" name="first_name">
While I want this as below
<input type="text" mendatory="true" placeholder="First Name" value="" id="student_personal_details-first_name" name="student_personal_details[first_name]">
What I'm doing wrong here?? could anyone help please??