I am trying to disable the required on that text input in my form.
However, even with
['required' => false], ['allowEmpty' => true]
which remove "required=required" from the HTML, I still get greeted with a 'This field cannot be left empty' when I try to make it be empty.
This string is located in Validator.php from what I see, but even though I tried editing or deleting what I thought was causing this, I did not find my way through. I'm using cakephp 3.0.2 Here's my little form :
<?php
echo $this->Form->create($schedule);
echo $this->Form->input('year', [array('type' => 'text', 'readonly' => 'readonly')]);
echo $this->Form->input('month',[array('type' => 'text', 'readonly' => 'readonly')]);
echo $this->Form->input('text', ['required' => false], ['allowEmpty' => true]);
echo $this->Form->button(__('Save'));
echo $this->Form->end();
?>
Thanks for the time you'll give me.
How is your model defined? Do you have a
public $validate = array()
defined? Are you sure you did not set required=true there, and did you set 'allowEmpty => true there? Because that's where that validation belongs rather than in the form, so you should first check you're not contradicting yourself.