Reputation: 255
So, in CakePHP 3, to get something like this:
I would do this:
<?= $this->Form->date('dob', [
'templates' => ['inputContainer' => '{{content}}'], 'label' => false, 'class' => 'form-control', 'minYear' => 1940, 'maxYear' => date('Y') - 5,
'empty' => [
'year' => "Year", // The year select control has no option for empty value
'month' => 'Month', // The month select control does, though
'day' => 'Day', // The month select control does, though
],
]) ?>
However, if I try to do the same thing on Cakephp 4, I get this
I've gone through the docs here: https://book.cakephp.org/3/en/views/helpers/form.html#creating-date-time-related-controls and https://book.cakephp.org/4/en/views/helpers/form.html
Please how can I achieve same Cakephp 3 output on Cakephp 4
Upvotes: 0
Views: 696
Reputation: 21743
Did you try
'type' => 'select'
as documented? Otherwise a custom template might help.
Alternatively, the dropdown default part was moved to Shim plugin See https://github.com/dereuromark/cakephp-shim/blob/master/docs/View/Form.md That should give you the 3.x way of creating such form elements.
Upvotes: 1