0

I have a date input and I wish to have the first option empty or blank. That way the user will have to select something, if not, validation will pick it up.

By default today's date preselected on load. I have managed to input a blank value but I cannot get it as the selected option.

echo $this->Form->input('date_of_birth', array('empty' => ''));

1 Answer 1

8

You should use boolean on empty attribute:

echo $this->Form->input('date_of_birth', array('empty' => true));
Sign up to request clarification or add additional context in comments.

1 Comment

I came here after setting 'empty' => true but finding that page refreshes were still keeping a set value displaying. Here 'F5' will keep the keep the existing value in the dropdown. Instead you need to go to fully reload the page by selecting the address bar and hitting enter.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.