Skip to content

Instantly share code, notes, and snippets.

@digitalkaoz
Created July 5, 2012 08:14
Show Gist options
  • Save digitalkaoz/3052236 to your computer and use it in GitHub Desktop.
Save digitalkaoz/3052236 to your computer and use it in GitHub Desktop.
form rendering bug
<!-- no extends -->
{% use 'form_div_layout.html.twig' with widget_attributes as base_widget_attributes %}
{% block widget_attributes %}
{% set full_name = name %}
{{ block('base_widget_attributes') }}
{% endblock widget_attributes %}
{% form_theme form _self %}
<!-- faulty block prints this -->
id="" name=""
<!-- end block prints -->
<!-- correct form rendering here -->
@digitalkaoz
Copy link
Author

solved with:

{% block widget_attributes %}
{% spaceless %}
{% if id is not empty %}id="{{ id }}" {% endif %} {% if name is not empty %}name="{{ name }}" {% endif %} {% if read_only %} readonly="readonly"{% endif %}{% if disabled %} disabled="disabled"{% endif %}{% if required %} required="required"{% endif %}{% if max_length %} maxlength="{{ max_length }}"{% endif %}{% if pattern %} pattern="{{ pattern }}"{% endif %}
{% for attrname, attrvalue in attr %}{% if attrname in ['placeholder', 'title'] %}{{ attrname }}="{{ attrvalue|trans({}, translation_domain) }}" {% else %}{{ attrname }}="{{ attrvalue }}" {% endif %}{% endfor %}
{% endspaceless %}
{% endblock widget_attributes %}

will submit a patch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment