model validation required but not exist

hi, i dont know how to name the question properly. but let me try my best to describe it.

there are a few fields they happen to capture input at the second step. so the scenario are ‘update’

and the fields are depends on the previous step and they need to be required (not empty, in fact they are files upload)

let say.

if

step 1 q1 choose a

step 2 we have q8 q9 and they need to not empty

if

step 1 q1 choose b

setp 2 we have q9 q10 q11 need to be not empty

the problem is. if i set them all validate rule not empty. i will never able to validate success. because q8, q9, q10, q11 will not be submit all together.

any solution?

How about demonstrating your challenge…

E.g

Goal - I want to build a multi-page form

My models has the following;

<model code sample here of problem code>

My controller has;

<controller sample>

My view has;

<view sample>

Then the errors you are getting…

Then result that you are hoping to get

This way help can be provided easier - right now I am not understanding your problem

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'=&gt;'create'),


array('captcha', 'captcha', 'allowEmpty'=&gt;&#33;CCaptcha::checkRequirements(),'on'=&gt;'create'),


array('type_id, world_id, status_id', 'numerical', 'integerOnly'=&gt;true),


array('email, reward_email, file_dump, file_log, file_spec, cid,version', 'length', 'max'=&gt;255),


array('email, reward_email', 'email' ),


array('desc1', 	'length', 'max'=&gt;16),


array('uid', 	'length', 'max'=&gt;26),


array('desc2', 	'length', 'max'=&gt;2000),


array('attach_dump'		,'file', 'allowEmpty' =&gt; true,'maxSize' =&gt; 1024 * 1024 * 5,'on'=&gt;'update'),

array(‘version’,‘safe’,‘on’=>‘update’),

array('attach_log'		,'file', 'allowEmpty' =&gt; true,'maxSize' =&gt; 1024 * 1024 * 1,'on'=&gt;'update'),


array('attach_spec'		,'file', 'allowEmpty' =&gt; true,'maxSize' =&gt; 1024 * 1024 * 1,'on'=&gt;'update'),


array('attach_screen'	,'file', 'allowEmpty' =&gt; true,'maxSize' =&gt; 1024 * 1024 * 1,'types'=&gt; 'jpg','on'=&gt;'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

Write a custom validation function, in that function validate your type_id if validation fails call

$this->addError() function

further information visit Validation rules