Validations are working but form is not getting submitted and data is not inserted:
addgroup.ctp:
echo $form->create('Group', array('url' => array('controller' => 'admin', 'action' =>'addgroup'), 'onSubmit' => 'return Validate()'));
echo $form->input('name',array('label' => false));
<input type="submit" value="Submit"/>
<input type="button" value="Cancel"/>
Group Model:
var $validate = array(
'name' => array(
'isRequired' => array(
'rule' => 'required',
'message' => 'Enter group name.'
),
'isUnique' => array(
'rule' => 'isUnique',
'message' => 'This group name has already been taken.'
),
),
);
in controller:
$this->Group->save($this->data,array('validate' => true)
If I make any empty entry or duplicate entry it gives errormessge,
but if I make valid entries then also form gives error-message,
What m I missing here?
you need to close the form
$this->Form->end('Submit');and the save function:$this->Group->save($this->data);It will validate when it saves.