Without using $form->error, cake will default to displaying the error unless you set 'error' => 'false' so you do not have to use $form- >error.
You can then define the error message in your model: var $validate = array( 'firstname' => array( 'rule' => 'alphaNumeric', 'required' => true, 'allowEmpty' => false, 'message' => 'First name is required and only alphanumeric characters are allowed' ), 'lastname' => array( 'rule' => 'alphaNumeric', 'required' => true ) ); Alternatively, you can set 'error' => 'false' and return from your controller an array of all errors, if any, using $this->Profile- >invalidFields(); On May 20, 10:58 am, Break <[EMAIL PROTECTED]> wrote: > Hey guys, i got a problem with the formhelper::error. > I'm know tryin for 2 days to fix this problem: > The validation in the code below works fine. if the field is empty the > setFlash-Msg appears and the data isn't saved. > But the error message doesnt appear. > > MODEL > ################################################################# > > class Profile extends AppModel { > var $name = 'Profile'; > var $belongsTo = array( > 'User' => array ( > 'foreignKey' => 'id' > ) > ); > var $validate = array( > > 'firstname' => array( > 'rule' => 'alphaNumeric', > 'required' => true > ), > > 'lastname' => array( > 'rule' => 'alphaNumeric', > 'required' => true > ) > > ); > } > > CONTROLLER > ############################################################ > > class ProfilesController extends AppController { > var $name = 'Profiles'; > > function index() { > if(!empty($this->data)) { > $this->Profile->id = $this->Session->read('id'); > if($this->Profile->save($this->data)) { > $this->Session->setFlash('Saved'); > } else { > $this->Session->setFlash('Error'); > } > } > > $this->Profile->id = $this->Session->read('id'); > $profile = $this->Profile->read(); > $this->set('profile', $profile); > } > > } > > VIEW > ########################################################################## > > <?=$form->create('Profile', array('action' => 'index'));?> > <?=$form->input('firstname', array('value' => $profile['Profile'] > ['firstname'], 'size' => 50, 'maxlength' => 100, 'label' => > 'Firstname', 'class' => 'input', 'div' => false));?><br /> > <?=$form->error('firstname', 'Please fill in firstname');?> > <?=$form->end();?> > > I hope you can help me. > (sorry for mistakes my english is not the best) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com 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 -~----------~----~----~----~------~----~------~--~---