Simple problem, but can't find my solution. I have a gallery upload field with multiple files like this:
echo $this->Form->input('Item.gallery.', array(
'label' => __('Gallery'),
'type' => 'file',
'multiple' => 'multiple',
));
And i got the validation rules like this:
'gallery' => array(
'fileSize' => array(
'rule' => array('fileSize', '<=', '1MB'),
'message' => 'Image must be less than 1MB',
'allowEmpty' => true,
'last' => false,
),
'extension' => array(
'rule' => array('extension', array('gif', 'jpeg', 'png', 'jpg')),
'message' => 'Invalid image',
),
),
If i put a single file upload field, then it is not required. When i set it to multiple, it is required and I don't want it to be. How do i do this?
EDIT:
The catch was setting 'required' => false
in the input field options, in the .ctp file:
echo $this->Form->input('Item.gallery.', array(
'label' => __('Gallery'),
'type' => 'file',
'multiple' => 'multiple',
'required' => false,
));
The validation rules in the model remained the same.