I need two different validation on a single form

i have one dropdownlist and a textfield when i click save button textfield must not be blank and this rule not applicable for dropdownlist when i click modify button we must select dropdownlist and textfield not be blank. how to do this

Use scenario-based validation. Please check the guide about this.

consider my source in model it gives following error

CException

Description

Property "AddModifyDeleteTypeForm.scenario" is not defined.

please hint

public function rules()

{


	return array(

            array('holidaytype', 'required','on'=>'modify','message'=>'You forgot to select Holiday Type.'),

            array('holidaytype', 'required','on'=>'delete','message'=>'You forgot to select Holiday Type.'),

				array('newholidaytype', 'required','on'=>'modify','message'=>'You forgot to fill New Holiday Type.'),

                    array('newholidaytype', 'required','on'=>'save','message'=>'You forgot to fill New Holiday Type.'),

                    );

}

then in controller

$form=new searchform;

$form->attributes=$_POST['searchform'];

if(isset($_POST['save']))

{

$form->scenario='save';

if($form->validate())

{

//operations

}

}

if(isset($_POST['modify']))

{

$form->scenario='modify';

if($form->validate())

{

//operations

}

}

if(isset($_POST['delete']))

{

$form->scenario='delete';

if($form->validate())

{

//operations

}

}

which Yii version are you using?

CModel::scenario has been available since 1.0.4.

yii 1.0.3