Reputation: 11285
In form I'm using model. In model I have defined validation rules. How I can disable specific rule in form without removing this in model.
I searching for something like that- for solution to set validate false for specific field example:
<?php echo $this->Form->input(
'phone',
array('type' => 'text',
'div' => array('class' => "input-wrap"),
'label' => false,
'validate' => false,
)
) ?>
Upvotes: 1
Views: 899
Reputation: 1
You can try this way also in the controller
unset($this->ExampleModel->validate['emailaddress']['unique']);
Upvotes: 0
Reputation: 8540
You want to alter the validation rules in your controller before you save the form rather than within the View.
For example, if you wanted to remove all validation rules for the phone
field:-
$this->ExampleModel->validator()->remove('phone');
If you just want to remove a specific rule from the field you can do that too. For example, if you have a rule named required
for the phone
field:-
$this->ExampleModel->validator()->remove('phone', 'required');
You can read up on this in the official docs.
Upvotes: 3