简体   繁体   中英

TWIG: form_widget with type number

I'm trying to change the "text" type of a input using Twig and Silex but looks that I'm doing something wrong.

This is the basic code I'm doing:

<div class='form-group'>
    {{ form_label("Id") }}
    {{ form_widget("id", { attr: { 'class': 'form-control' }}) }}
</div>

I want that this id field be an integer.

in Symfony you need to change the type in your formtype:

->add('streetNo', NumberType::class, ['required' => true])

For older versions of Symfony it looks like this:

->add('streetNo','number', ['required' => true])

The twig "doesn't care" about the input type. I would think that it is the same for Silex as it is build on Symfony.

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