I want to use angularJS in a zend framework project and in this project forms are generated using zend form. How can I add angular directive such as "ng-model" in the form elements but whenever i was trying to add this custom attribute in the zend-form elements (input, select etc) in view I am not getting this attribute ----
Here is my lead form
class LeadForm extends Form {
public function __construct() {
parent::__construct('lead_form');
$this->setAttributes(array(
'action' => '',
'method' => 'post',
'name' => 'lead_form',
'id' => 'lead_form',
'class' => 'smart-form',
'role' => 'form',
'novalidate' => 'novalidate'
));
$this->add(array(
'name' => 'first_name',
'type' => 'text',
'options' => array(
'label' => 'First Name',
),
'attributes' => array(
'class' => 'form-control validate[required,custom[onlyLetterSp]]',
'placeholder' => 'First name',
**'ng-model' => "first_name", // this attribute is not generating in view**
),
));
}
}
Here is my controller which is calling this form and send to view for displaying
$createLeadForm = new \Admin\Form\LeadForm();
return new ViewModel(array(
'form' => $createLeadForm,
));
Here is my code in view for showing element
<?php echo $this->formInput($this->form->get('first_name')); ?>
But after prinnting this form element i am getting see no "ng-model" in the input element
<input type="text" value="" placeholder="First name" class="form-control validate[required,custom[onlyLetterSp]]" name="first_name" >
I have set one attribute "ng-model " but this attribute is not appearing in the view
I want this element like (using zend form ) -
<input type="text" ng-model="first_name" value="" placeholder="First name" class="form-control validate[required,custom[onlyLetterSp]]" name="first_name" >
How can I do that using zend form and what need to change in this form and why i can not able to add custom attribute? please help me.
Thanks in Advance