I've got a form that allows a file upload and I'm using data validation to check what type of file it is and that's all good. What I want to do is then allow them to edit that same record but a file upload at that time is not needed.
My validation rule is as follows:
'header_pic' => array(
'extension' => array(
'rule' => array('extension', array('jpeg', 'jpg', 'gif', 'png')),
'message' => 'You must supply a GIF, PNG, or JPG file.',
)
)
But this rule requires a file. I found the 'on' parameter and I could add it to this rule but it would then only check files on creation. Not on editing.
I tried this but it didn't work:
'header_pic' => array(
'extension' => array(
'rule' => array('extension', array('jpeg', 'jpg', 'gif', 'png')),
'required' => false,
'allowEmpty' => true,
'message' => 'You must supply a GIF, PNG, or JPG file.',
),
'notEmpty' => array(
'rule' => array( 'notEmpty'),
'on' => 'create',
'message' => 'You must supply a file.',
),
)
What am I missing? (Thanks in advance!!)