user1291904
user1291904

Reputation: 63

Symfony2 custom (HTML5) date field creation

My target is to create a custom Date field (which should work with Doctrine). The main difference with the basic Symfony's one is that it shouldn't be 3 dropdowns, but one <input type="date">.

I've tried several tutorials like Symfony's book and some helpful answers here.

However the more solutions I try to embed, the more problems I see.

Could anybody write or advise the tutorial for this task?

Thanks in advance.

Upvotes: 4

Views: 1937

Answers (2)

Prisoner
Prisoner

Reputation: 27618

In Symfony >= 2.6 they introduced a html5 option which will generate a HTML5 input element.

You can see the documentation here: http://symfony.com/doc/current/reference/forms/types/date.html#html5

Upvotes: 0

Elnur Abdurrakhimov
Elnur Abdurrakhimov

Reputation: 44831

The date field type supports that already. Just set the widget option to single_text and voila — you'll have what you want. No need to create a special type for that. :)

Upvotes: 6

Related Questions