Skip to content

Commit

Permalink
Add icons to form buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
Miha Vrhovnik committed Feb 19, 2014
1 parent 426e332 commit f9b558a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion Resources/views/Form/bootstrap.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@
{% else %}
{% set attr = attr|merge({ 'class': (attr.class|default('') ~ ' btn btn-default')|trim }) %}
{% endif %}
<button type="{{ type|default('button') }}" {{ block('button_attributes') }}>{{ label|trans({}, translation_domain) }}</button>
<button type="{{ type|default('button') }}" {{ block('button_attributes') }}>{% if attr.icon is defined and attr.icon != '' %}{{ icon('attr.icon') }}{% endif %}{{ label|trans({}, translation_domain) }}</button>
{% endspaceless %}
{% endblock button_widget %}

Expand Down

4 comments on commit f9b558a

@althaus
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it be easier to use the parse_icon filter for the label?

@mvrhov
Copy link
Contributor

@mvrhov mvrhov commented on f9b558a Mar 18, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO no. The main Reason being that the icons will be present in translation text. Which you usually do not want.

@althaus
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh didn't tought of that. That makes sense.

What I now miss is the space between icon and label. According to the Bootstrap page: "Be sure to leave a space between the icon and text for proper padding."

<button type="button" class="btn btn-default btn-lg">
  <span class="glyphicon glyphicon-star"></span> Star
</button>

So I'd add that space in front of the {% endif %}.

@mvrhov
Copy link
Contributor

@mvrhov mvrhov commented on f9b558a Mar 19, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can solve that with css.

Please sign in to comment.