Newline (lt;brgt;) between radio choices in Symfony form(Symfony 形式的电台选项之间的换行符 (lt;brgt;))
问题描述
我有这个表单生成代码..:
I have this form generation code..:
$form = $this->createFormBuilder($task)
->add('mode', 'choice', array(
'label' => false,
'choices' => array(
'mode1' => '1',
'mode2' => '2',
'mode3' => '3',
),
'multiple' => false,
'expanded' => true,
'required' => true,
))
->getForm();
问题在于呈现的表单具有内联选项(无线电输入),它们之间没有 <br/>
标记.
The problem is that rendered form has choices (radio inputs) inline, without <br/>
tags between them.
另外,我找不到如何使用 twig 模板呈现表单,所以不要触摸 PHP 代码,例如,我如何在我的单选按钮列表中专门装饰"每个选项.
Also, i cannot find how do i render form with a twig template so do not touch PHP code, for example, how can i specially 'decorate' each choice in my radio buttons list.
<div style='margin:25px'>
{{ form_start(form_options) }}
{{ form_widget(form_options) }}
{{ form_end(form_options) }}
</div>
如何扩展它?
推荐答案
你可以随意渲染每个表单域.不要使用 {{ form_widget(form_options) }}
使用 {{ form_row (form.fieldName) }}
然后您可以根据需要添加 html 和样式:这是一个例子:
You can render each form field as you like. Do not use {{ form_widget(form_options) }}
use {{ form_row (form.fieldName) }}
then you can add html and style as you like : This is an exemple :
<div class="checkbox-list">
<label class="checkbox-inline col-md-6">
<div class="checker" id="uniform-inlineCheckbox21">
<span class="">
{{form_row(form.fieldName)}}
</span>
</div>
fieldName
</label>
您还可以传递对象列表并手动创建您的输入:
You can also pass a list of object and create manually your input :
{% for language in languages %}
<div class="checkbox-list">
<label class="checkbox-inline col-md-6">
<div class="checker" id="uniform-inlineCheckbox21">
<span class="">
<input type="checkbox" name="langues[]" id="course{{loop.index}}" value="{{language.id}}" data-title="e3tsYW5ndWFnZS5kZXNpZ25hdGlvbn19">
</span>
</div>
{{language.designation}}
</label>
</div>
{% endfor %}
最后一个解决方案,您可以使用 form_theme 并通过 symfony 覆盖选择小部件用户:http://symfony.com/fr/doc/current/cookbook/form/form_customization.html
Last solution you can use form_theme and override the choices widget user by symfony : http://symfony.com/fr/doc/current/cookbook/form/form_customization.html
这篇关于Symfony 形式的电台选项之间的换行符 (<br>)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Symfony 形式的电台选项之间的换行符 (<br>)
- SoapClient 设置自定义 HTTP Header 2021-01-01
- 如何定位 php.ini 文件 (xampp) 2022-01-01
- 正确分离 PHP 中的逻辑/样式 2021-01-01
- 没有作曲家的 PSR4 自动加载 2022-01-01
- 从 PHP 中的输入表单获取日期 2022-01-01
- Mod使用GET变量将子域重写为PHP 2021-01-01
- Laravel 仓库 2022-01-01
- Oracle 即时客户端 DYLD_LIBRARY_PATH 错误 2022-01-01
- PHP Count 布尔数组中真值的数量 2021-01-01
- 带有通配符的 Laravel 验证器 2021-01-01