Hai

I want to validate the user input from the text box from the form to
be not empty before saving it.
I used the following code....but it is not working.

This one is in models_controller

function add()
{
        if(!empty($this->data))
        {
                $ModelName=$this->data['models']['ModelName'];
                $this->Model->set($ModelName);
                if($this->Model->validates())
                {
                        if($this->Model->saveField('ModelName',$ModelName))
                        {
                                $this->Session->setFlash('Model Saved 
Successfully');
                                $this->redirect('/vehicles/index');
                        }

                }
                else
                {
                $this->Session->setFlash('Error with Model Name,Should not be
empty.');
                }




        }
}

This one is in my Model

var $validate = array(
    'ModelName' => array(
    'rule' => 'notEmpty',
    'allowEmpty=>false,
    'required' => true,
    'message' => 'This field cannot be left blank'
    )
    );

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to