How can I show and hide form elements in CakePHP based on a dropdown selection:
Outside of CakePHP, I would usually use jquery or ajax but I cant seem to find anything that tells you how to do this with this scenario in CakePHP.
Here is what I have in the view:
<?php echo $this->Form->create('Spec'); ?>
<fieldset>
<legend><?php echo __('Add Spec'); ?></legend>
<?php
echo $this->Form->input('ref');
echo $this->Form->input('service_id',array('empty'=>'Please Select'));
echo $this->Form->input('a1',array(
'label' => 'Background:',
'div' => false
));
echo $this->Form->input('a2',array(
'label' => 'Business objectives:',
'div' => false
));
When I select a 'service', dependent on my selection I need to either show or hide a1 and a2.