I have two fields in my form named start date and end date. I want to validate end date only if start date is present.
In rails, we have :if. Do we have anything similar in yii?
Define your custom function for validation .
define rule :
array('end_date','checkEndDate');
define custom function:
public function checkEndDate($attributes,$params)
{
if($this->start_date){
if(!$this->validate_end_date($this->end_date))
$this->addError('end_date','Error Message');
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With