Get options of an entity Field in twig

和自甴很熟 提交于 2019-12-31 07:11:18

问题


I have an entity field that is passed to twig view, It is rendered and works fine. Is it possible to get the <option> values of that field and render them somewhere else ( I need another select with the same values of that entity field >. say this is my entity field

{{ form_widget(entity_field) }}

I want something like this

<select id="just_another_select">
 {% for value in entity_field.values %} <- how to get entity_field.values 
    <option > value </option> 
  {% endfor %}

回答1:


Yes you can get all your options by accesing your field vars see this

{{ dump(form.YourFieldName.vars['choices']) }}


来源:https://stackoverflow.com/questions/29430139/get-options-of-an-entity-field-in-twig

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!