0

I have a form with a datetime rendered as 5 select inputs d MM YYYY H-i

$builder
        ->add('date', 'datetime',
            array(
                'data' => new \DateTime('now'), //default value
                'format' => 'd-MM-yyyy H-i-s',
                'years' => array(2016, 2017),
            )
        )
        ->getForm();

enter image description here

I would like to customize the template and hide the character ":" between the minutes and seconds select inputs. How can I achieve this?

1 Answer 1

2

I finally found the solution. The datetime field can be rendered as more select inputs in twig template like this:

{{ form_widget(form.date.date.day) }}
{{ form_widget(form.date.date.month) }}
{{ form_widget(form.date.date.year) }}
{{ form_widget(form.date.time.hour) }}
{{ form_widget(form.date.time.minute) }}
Sign up to request clarification or add additional context in comments.

Comments

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.