Skip to content

Commit a1c83d2

Browse files
committed
bug #424 Use font-awesome icon in "form_errors" block (yceruto)
This PR was merged into the master branch. Discussion ---------- Use font-awesome icon in "form_errors" block By default [`bootstrap_3_layout.html.twig` template use `glyphicon-` icon when the `form_errors` block is rendered](https://github.com/symfony/symfony/blob/master/src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_3_layout.html.twig#L259). In this demo app we use font-awesome (`fa-`) icon library, so this PR try to fix that. | Before | After | | ---- | ---- | | ![post-comment-error](https://cloud.githubusercontent.com/assets/2028198/21733360/1098de26-d42c-11e6-92f7-a8f5b54e09b1.png) | ![post-comment-fixed](https://cloud.githubusercontent.com/assets/2028198/21733425/5fddca46-d42c-11e6-9ede-4e1846aa01f7.png) | Commits ------- 8b746b6 use font-awesome icon in "form_errors" block
2 parents 21f82cc + 8b746b6 commit a1c83d2

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{% extends 'bootstrap_3_layout.html.twig' %}
2+
3+
{# Errors #}
4+
5+
{% block form_errors -%}
6+
{% if errors|length > 0 -%}
7+
{% if form.parent %}<span class="help-block">{% else %}<div class="alert alert-danger">{% endif %}
8+
<ul class="list-unstyled">
9+
{%- for error in errors -%}
10+
{# use font-awesome icon library #}
11+
<li><span class="fa fa-exclamation-triangle"></span> {{ error.message }}</li>
12+
{%- endfor -%}
13+
</ul>
14+
{% if form.parent %}</span>{% else %}</div>{% endif %}
15+
{%- endif %}
16+
{%- endblock form_errors %}

app/config/config.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,15 @@ twig:
5555
debug: "%kernel.debug%"
5656
strict_variables: "%kernel.debug%"
5757
form_themes:
58-
- "bootstrap_3_layout.html.twig"
58+
- "form/layout.html.twig"
5959
- "form/fields.html.twig"
6060

6161
# Doctrine Configuration (used to access databases and manipulate their information)
6262
doctrine:
6363
dbal:
6464
# if you don't want to use SQLite, change the URL in parameters.yml or set the DATABASE_URL environment variable
6565
url: "%env(DATABASE_URL)%"
66-
66+
6767
# instead of using a URL, you may also uncomment the following lines to configure your database
6868
# driver: pdo_mysql
6969
# host: "%database_host%"

0 commit comments

Comments
 (0)