简体   繁体   中英

How to pass a variable to a twig block in Symfony2

I am displaying a date time widget in a web page I am developing. By default time part only show hours and minutes. I need to show seconds too.

I have found that the date time wtdget has a variable called with_seconds, but I need to pass true from the form.

This is what I have but it did not work:

{{ form_widget(edit_form.fechhoramarcada, { 'attr': {'class': 'input-text no-border'}, 'with_seconds': true }) }}

Any help will be appreciated,

Thanks Jaime

You can change default options when you creating them.

$builder->add('fechhoramarcada', 'datetime', array(
    'with_seconds'    => true,
));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM