[eluser]McNoggin[/eluser]
I am creating a form with a drop down list that allows the user to pick an existing value. If the value they want isn't in the list they can select 'Other' and will then be allowed to enter a new value into an input field.
Currently I have the validation rules setup to require both the dropdown value, and the new input value. I'd like to know if there is a way to configure the second field to only be required if a specific value in the other field is set.
To clear things up here is what the HTML looks like
Code:
<select name="choice_id">
<option value="1">Choice 1</option>
<option value="2">Choice 2</option>
<option value="-1">Other</option>
</select>
<input type="text" name="choice_name" />
In my controller I have these rules
Code:
$rules['choice_id'] = "required";
$rules['choice_name'] = "required";
However what I really want is way set it up so that 'choice_name' is only required if 'choice_id' is equal to -1.