Reputation: 157
I want to get two input fields for hours and minutes with the TimeType
field.
I also want to set for the input field of time and hour an unique label, placeholder and / or input values. I also want to render each inpult field individually in TWIG, like
{{ form_row(form.TimeExtern[####HOUR FIELD####]) }}
{{ form_row(form.TimeExtern[####MINUTES FIELD####]) }}
My current code:
$builder->add('TimeExtern', 'time', array(
'input' => 'timestamp',
'widget' => 'single_text',
'required' => true,
'label' => 'Externe Zeit',
'attr' => array(
'help_text' => 'Zeitformat: Stunden:Minuten',
'input_group' => array(
'append' => '.icon-time',
)
),
));
This gives me ONE input field for hour and minutes together. I've already read the docs but couldn't find a solution.
Any ideas?
Upvotes: 1
Views: 2476
Reputation: 17759
The form_div_layout.html.twig
renders the time widget using
{{ form_widget(form.hour, vars) }}
{% if with_minutes %}:{{ form_widget(form.minute, vars) }}{% endif %}
{% if with_seconds %}:{{ form_widget(form.second, vars) }}{% endif %}
So as far as I can see you would be able to use
{{ form_widget(form.TimeExtern.hour) }}
{{ form_widget(form.TimeExtern.minute)) }}
And then just add your details (label, placeholder, etc) in the attributes hash like
{{ form_widget(form.TimeExtern.hour, {'label': '', 'attr': {'placeholder': '' }}) }}
{{ form_widget(form.TimeExtern.minute, {'label': '', 'attr': {'placeholder': '' }}) }}
Upvotes: 0