I have a datetime control in CakePHP
and I am trying to make it readonly (readonly
attribute works fine with textfields).
So this is what I have tried:
CakePHP way:
echo $this->Form->control('date_start', ['empty' => true, 'readonly' => 'readonly']);
OR
echo $this->Form->control('date_start', ['empty' => true, 'readonly' => 'true']);
JavaScript:
$this->Html->scriptBlock("document.getElementById('#datestart').readonly = true;");
echo $this->Form->control('date_start', ['id' => 'datestart', 'empty' => true]);
But none of them works. How I can achieve what I want.