EllisLab text mark
Advanced Search
     
Set validation rule depending on another rule?
Posted: 07 September 2007 03:43 PM   [ Ignore ]
Avatar
Joined: 2006-04-27
45 posts

I have the following form:

Text Field: Reg Number
Text Field: Odometer Reading - optional
Radio Group: Odometer Type - optional
- Radio 1: Miles
- Radio 2: Kilometers

Notice how both Odometer Reading and Odometer Type are optional to begin with. What I’d like to do is change the Odometer Type Radio Group to required ONLY if Odometer Reading has been entered.

Is this possible?

 
Posted: 07 September 2007 04:08 PM   [ Ignore ]   [ # 1 ]   [ Rating: 0 ]
Avatar
Joined: 2006-06-16
319 posts

I think you’ll have to use this:

if ($this->post->input('odometer_reading')) {
    $rules[
'odometer_type'"required";
 Signature 

Best regards. Zacharias.
Matchbox (Modular Separation) | Wick (Controller Loader)