只是想知道在使用formbuilder在html twig中创建表单时如何将文本框与标签分开?表单工作正常,但我想将每个新文本框和前一个文本框下方的文本对齐,这样它就不会看起来那么草率。有没有办法可以渲染表单,然后设置样式?我正在使用 php 用 formBuilder 创建表单,并用 twig 渲染它。
用于创建表单的 php 如下所示:
$form = $this->createFormBuilder(array('csrf_protection' => false))
->add('username','text', array('label'=>'Username/Alias'))
->add('password','password',array('label'=>'Password'))
->add('ve','text',array('label'=>'Verification code'))
->getForm() ;
$request= $this->getRequest();
树枝看起来像这样:
<form action="{{path('myBundle_login')}}" method="post" enctype={{form_enctype(form)}}>
// the form_enctype(form) is the form that is sent through
{{ form_errors(form) }}
{{ form_widget(form) }}
{{ form_rest(form) }}
但我只是希望它整齐地间隔...请帮忙。