Hey, guys, I’m trying to do this:
I have a form in which users can create or update data. In this form I have a file which should be required only in creation time, not in update scenario.
I’ve tried this:
array(‘upFile’, ‘file’, ‘types’=>‘jpg,JPG’,‘allowEmpty’=>true ,‘wrongType’=>‘Only jpg allowed’,‘on’=>‘update’),
array(‘upFile’, ‘file’, ‘types’=>‘jpg,JPG’,‘allowEmpty’=>false ,‘wrongType’=>‘Only jpg allowed’,‘on’=>‘create’),
And in my controller/action update:
$model->scenario = ‘update’;
controller/action create:
$model->scenario = ‘create’;
I also tried this:
array(‘upFile’, 'required, ‘on’=>‘create’);
array(‘upFile’, ‘file’, ‘types’=>‘jpg,JPG’,‘allowEmpty’=>true ,‘wrongType’=>‘Only jpg allowed’,‘on’=>‘update’),
But for both update and create actions I got the message like “file can’t be blank…”
Could you please tell me what I’m doing wrong?
Thank you very much