I want to update a record with different validation rules
my model has following rules
array('type_id, world_id, create_date, uid, status_id,email,reward_email,desc1,desc2', 'required'),
array('captcha', 'required','on'=>'create'),
array('captcha', 'captcha', 'allowEmpty'=>!CCaptcha::checkRequirements(),'on'=>'create'),
array('type_id, world_id, status_id', 'numerical', 'integerOnly'=>true),
array('email, reward_email, file_dump, file_log, file_spec, cid,version', 'length', 'max'=>255),
array('email, reward_email', 'email' ),
array('desc1', 'length', 'max'=>16),
array('uid', 'length', 'max'=>26),
array('desc2', 'length', 'max'=>2000),
array('attach_dump' ,'file', 'allowEmpty' => true,'maxSize' => 1024 * 1024 * 5,'on'=>'update'),
array(‘version’,‘safe’,‘on’=>‘update’),
array('attach_log' ,'file', 'allowEmpty' => true,'maxSize' => 1024 * 1024 * 1,'on'=>'update'),
array('attach_spec' ,'file', 'allowEmpty' => true,'maxSize' => 1024 * 1024 * 1,'on'=>'update'),
array('attach_screen' ,'file', 'allowEmpty' => true,'maxSize' => 1024 * 1024 * 1,'types'=> 'jpg','on'=>'update'),
there is type_id will affect the fields on the update form
the fields are : version, attach_log, attach_spec, attach_screen, and attach_dump
example type_id is 1
the form will require attach_dump
type_id is 2
the form will require attach_screen and version
type_id is 3
the form will require attach_dump and attach_log
etc…
i can only set allowEmpty=>true and version as safe… because they are not all required in the update.
if i remove the allowEmpty=>true
then $model->save() in the controller. the validation will always failed… because other fields are required to validate.
do u understand the different case in update?
so i need to a solution to validate all provided fields must not empty, but those not provided field dont validate… that’s all