system
(system)
1
Hello,
I have these rules on Customer active record/model:
public function rules()
{
return array(
array('name','length','max'=>128),
array('address','length','max'=>128),
array('phone','length','max'=>50),
array('excel_file','file','types'=>'xls'),
array('name', 'required'),
array('excel_file', 'required', 'on'=>'create'),
);
But in update action triggers a required error. I guess that the 'types' rules introduces the required constraint.
How to solve this ?
Raoul
(Manu34)
2
hi,
did you try to set the allowEmpty parameter to true ?
array('excel_file','file','allowEmpty' => true, 'types'=>'xls'),
I've not tested it but it should work.
system
(system)
3
It worked partially,
the allowEmpty rule overwrites the required rule
array('excel_file','file', 'allowEmpty' => true, 'types'=>'xls'), // <- this rule...
array('excel_file', 'required', 'on'=>'create'), // ...makes this rule unusable
Thanks Raoul