Symfony 6:使用单选按钮自定义表单

fdx2calv  于 2023-01-02  发布在  其他
关注(0)|答案(1)|浏览(106)

我有一个表单,想用symfony自定义它:

<input type="radio" name="type" value="auto" onClick="getMarques('auto')" id="check1">
<label class="s-submitCheckLabel" for="check1"><span class="m-circle"></span></label>
<label class="s-submitCheck" for="check1">Auto</label>

我已经试过了:

{% for child in formAnnonce.category %}
 
 {{ form_widget(child, {'attr' : {'class': 'form-check-input'}, {'name': 'type'}, {'id': 'check1'} }) }}
        {{ form_label(child)}}
        {{ form_help(child) }}
        {{ form_errors(child) }}


{% endfor %}
9jyewag0

9jyewag01#

{% for child in formAnnonce.category %} 
   {{ form_widget(child, {'attr': {'onclick': 'getMarques("' ~ child.vars.value~'")'}})}}
   <label class="s-submitCheckLabel" for="{{ child.vars.id }}"><span class="m-circle"> </span></label> 
   <label class="s-submitCheck" for="{{ child.vars.id }}">{{ child.vars.label </label> 
{% endfor %}

相关问题