I have a form set up with a file upload for profile pictures, and I'm validating the file upload like so:
'picture' => array(
'kosher' => array(
'rule' => 'validateImage',
'message' => 'Only images are allowed to be uploaded'
),
'size' => array(
'rule' => array('fileSize', '<=', '2MB'),
'message' => 'Picture must be less than 2 MB'
)
)
The validation runs, and works, however no validation errors are shown on the form when I submit incorrect data. I'm building the entire form like so:
<?php echo $this->Form->create('Profile', array('type' => 'file')); ?>
<?php echo $this->Form->hidden('id'); ?>
<?php echo $this->Form->label('Profile.picture', 'Profile picture'); ?>
<?php echo $this->Form->file('picture'); ?>
<?php echo $this->Form->input('firstname'); ?>
<?php echo $this->Form->input('lastname'); ?>
<?php echo $this->Form->input('email', array('between' => 'This is the email other users will use to contact you')); ?>
<?php echo $this->Form->input('Skill', array('type' => 'text', 'value' => $skills, 'label' => 'Your skills (seperate each skill by space)')); ?>
<?php echo $this->Form->input('course'); ?>
<?php echo $this->Form->input('bio'); ?>
<?php echo $this->Form->end('Save changes'); ?>
The other fields error messages get shown correctly, just not the file upload. How can I make the validation errors show up around the file input?
'picture'is defined as an array for<?php echo $this->Form->file('picture'); ?>but notsize. Far as I can tell.'size'is not being echo'ed anywhere, as compared to'picture','firstname'etc. Isn't the error message for the file upload'message' => 'Picture must be less than 2 MB'?<?php echo $this->Form->file('size'); ?>somewhere. Then again, I may be wrong.