nimrod
nimrod

Reputation: 5742

Ignore hour and minute selectors in form input in CakePHP (2.6.x)

How can I tell CakePHP to only show day, month and year and set hour, minute and second to 00 by default?

echo $this->Form->input('date', array('dateFormat' => 'DMY', 'timeFormat' => 24));

CakePHP always creates this form-input but I am not interested in hours, minutes and seconds:

enter image description here

Upvotes: 0

Views: 182

Answers (1)

Oldskool
Oldskool

Reputation: 34877

The FormHelper inspects your Model's datasource (or it's cache in production) to see what type of data you're trying to store there and it creates input elements that match it.

If you're not interested in the time, try altering the field in your database table to be a DATE field rather then a DATETIME field. The FormHelper should then automatically drop the time fields, since they cannot be stored anyway. You may need to clear your Model cache before the change takes effect.

Upvotes: 1

Related Questions