我有一个为个人资料图片上传文件的表单,我正在验证文件上传,如下所示:
'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'
)
)
验证运行,并且有效,但是当我提交不正确的数据时,表单上没有显示验证错误。我正在构建整个表单,如下所示:
<?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'); ?>
其他字段错误消息正确显示,而不是文件上传。如何使验证错误显示在文件输入周围?