you can user cakephp validation here the example form cakephp validation.
in your model you can user this code.

var $validate = array(
                    'field_name' => array(
                              'rule' => array(
                                        'minLength',
                                        1),
                                        'required' => true,
                                        'allowEmpty' => false,
                                        'message' => 'Please enter a value
for the Name field'));

in the view you can user this code:

?php if ($form->isFieldError('Model_name.Field_name')){

            e($form->error('Model_name.Field_name',
                            null,
                            array(
                            'class' => 'failure')
                          ));
        }
    ?>
try this i will work..









On Sat, May 22, 2010 at 12:20 PM, Ed Propsner <crotchf...@gmail.com> wrote:

> I have a form that is not displaying validation errors like it should be.
> The errors are there in the validationErrors array so the model is
> validating, I'm sure of that.
> I've been reading through a few other threads on the same subject but none
> of the causes seem to apply.
>
> I have the controller and the model stripped down to next to nothing.
>
> [controller]
>
> function add()
> {
>  if(!empty($this->data))
> {
> $this->data['ProfileAttrib']['user_id'] = $this->Auth->User('id');
>  $this->ProfileAttrib->save($this->data);
> }
> }
>
> [/controller]
>
> Then in the model I validate field 'gender'
>
> [model]
>
> class ProfileAttrib extends AppModel
>  {
>
> var $name = 'ProfileAttrib';
>
>  var $validate = array(
>       'gender' => array(
> 'rule' => 'notEmpty',
>  'message' => 'Message here'
> )
>      );
> }
>
> [/model]
>
> I also stripped down the view to just a form and a single field for
> gender.
> Whatever the reason is that validation messages aren't displaying I'm
> really not seeing it.
> I can't strip things down any more than what they are now.
>
> Any advice?
>
> - Ed
>
> Check out the new CakePHP Questions site http://cakeqs.org and help others
> with their CakePHP related questions.
>
> 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
> cake-php+unsubscr...@googlegroups.com<cake-php%2bunsubscr...@googlegroups.com>For
>  more options, visit this group at
> http://groups.google.com/group/cake-php?hl=en
>

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to