Created
July 2, 2020 14:04
-
-
Save nuryagdym/a3705ed8c6c35f914155ab73d8087662 to your computer and use it in GitHub Desktop.
Symfony Form Builder Bootstrap 4 input-group Append and Prepend
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% use "bootstrap_4_layout.html.twig" %} | |
{# extend form_widget_simple #} | |
{% block form_widget_simple -%} | |
{%- if (prepend is defined) or (append is defined) -%} | |
<div class="input-group{{ group_class|default('') }}"> | |
{%- if prepend is defined -%} | |
<div class="input-group-prepend"> | |
{{ prepend|raw }} {# without raw filter the html code will be escaped #} | |
</div> | |
{%- endif -%} | |
{{- parent() -}} | |
{%- if append is defined -%} | |
<div class="input-group-append"> | |
{{ append|raw }} | |
</div> | |
{%- endif -%} | |
</div> | |
{%- else -%} | |
{{- parent() -}} | |
{%- endif -%} | |
{%- endblock form_widget_simple %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% form_theme form 'my_bootstrap_4_layout.html.twig' %} | |
{{ form_start(form) }} | |
{{ form_row(form.facebook, {'prepend': '<button class="btn btn-icon btn-facebook"><i class="fab fa-facebook-f"></i></button>'}) }} | |
{{ form_row(form.area, {'append': '<span class="input-group-text" id="basic-addon1">m²</span>'}) }} | |
{{ form_end(form) }} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment