Referencia de valor de campo de representación de formulario de Symfony

ok, Formularios Symfony have always been a hell to understand for me, but now I decided to learn how they work! I just started and already a problem I can't figure out how to solve.

I have a random form with simple text inputs. The thing is, I want to disable browser autocompletion in them. (Add autocomplete="off" atributo).

So, I just copied default form_widget_simple block into my template:

{% form_theme form _self %}

{% block form_widget_simple %}
{% spaceless %}
    {% set type = type|default('text') %}
    <input type="{{ type }}" {{ block('widget_attributes') }} {% if value is not empty %}value="{{ value }}" {% endif %}>
{% endspaceless %}
{% endblock form_widget_simple %}

The problem is: When trying to render the template without changing anything Me sale este error:

Variable "value" does not exist in FILE/PATH/HERE on line LINE HERE

It looks like it's searching for value variable in template's context, which doesn't exist instead of using form field's value.

What should I change {{ value }} a ?

preguntado el 05 de mayo de 13 a las 21:05

1 Respuestas

IMO you are looking in wrong place. If you want to disable form auto completion you should add autocomplete=off in the form tag not the input tag.

If you want to add custom attribute to any of the input elements, again, you don't have to use form themes but use attr key in the form type class.

contestado el 05 de mayo de 13 a las 21:05

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.