I need to change the requirment of an input when a select change. I have this declaration on my form:
$name = $this->addElement('text', 'name', array(
'required' => true,
'label' => 'Name',
'filters' => array('StringTrim'),
));
I try with jquery in phtml file (view) :
$('#select').change(function(){
$('#name').prop('disabled', true);
})
but not work, the input continue to be required. Anyone can heklp me?
Stefania
You must remove required from the PHP side.
I can propose you this:
In your form, add an hidden element like this:
In your javascript :
In your controller, try something like this: