'message' key-value should be in 'imageupload' array, not in 'rule' one. You messed braces.
On Mar 5, 9:49 pm, ryanam1 <[email protected]> wrote: > Hi, > > I am new to CakePHP and I am having trouble getting the extension > error message to display. The error message for the email rule > displays fine when someone enters an improperly formatted email and I > tried other examples of Cake's built in validation, they all seem to > work fine except for the extension validation. Can someone please > tell me what I am doing wrong. > > Here are the validation rules in my model: > var $validate = array( > 'imageupload' => array( > 'rule' => array('extension', array('gif', 'jpeg', 'png', > 'jpg'), > 'message' => 'Please supply a valid image.' > ) > ) > , > 'email'=>array( > 'rule'=>'email', > 'message'=>'Please enter a proper email' > ) > ); > > Here is the snippet code in the Controller: > function add(){ > if (!empty($this->data)) { > > if($this->Student->save($this->data)){ > > $this->flash('Success','/add'); > } > } > } > > Finally the snippet code in my view: > <?PHP > echo $form->create('Student',array('type' => 'file')); > echo $form->input('email'); > echo $form->file('imageupload'); > echo $form->end('Add'); > ?> > > Again, the display message for the email displays correctly so I know > that the validation is working at least somewhat. The validation for > the file upload seems to operate correctly. If I try to upload a file > with a .DOC extension the "save" fails except that it does not display > the error message at all. > > Please help.... what am I doing wrong? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---
