-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
[TwigBridge] Add form templates for Bootstrap 5 #39157
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
130 changes: 130 additions & 0 deletions
130
src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_5_horizontal_layout.html.twig
This file contains hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
{% use "bootstrap_5_layout.html.twig" %} | ||
|
||
{# Labels #} | ||
|
||
{% block form_label -%} | ||
{%- if label is same as(false) -%} | ||
<div class="{{ block('form_label_class') }}"></div> | ||
{%- else -%} | ||
{%- set row_class = row_class|default(row_attr.class|default('')) -%} | ||
{%- if 'form-floating' not in row_class and 'input-group' not in row_class -%} | ||
{%- if expanded is not defined or not expanded -%} | ||
{%- set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' col-form-label')|trim}) -%} | ||
{%- endif -%} | ||
{%- set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' ' ~ block('form_label_class'))|trim}) -%} | ||
{%- endif -%} | ||
{{- parent() -}} | ||
{%- endif -%} | ||
{%- endblock form_label %} | ||
|
||
{% block form_label_class -%} | ||
col-sm-2 | ||
{%- endblock form_label_class %} | ||
|
||
{# Rows #} | ||
|
||
{% block form_row -%} | ||
{%- if expanded is defined and expanded -%} | ||
{{ block('fieldset_form_row') }} | ||
{%- else -%} | ||
{%- set widget_attr = {} -%} | ||
{%- if help is not empty -%} | ||
{%- set widget_attr = {attr: {'aria-describedby': id ~"_help"}} -%} | ||
{%- endif -%} | ||
{%- set row_class = row_class|default(row_attr.class|default('mb-3')) -%} | ||
{%- set is_form_floating = is_form_floating|default('form-floating' in row_class) -%} | ||
{%- set is_input_group = is_input_group|default('input-group' in row_class) -%} | ||
{#- Remove behavior class from the main container -#} | ||
{%- set row_class = row_class|replace({'form-floating': '', 'input-group': ''}) -%} | ||
<div{% with {attr: row_attr|merge({class: (row_class ~ ' row' ~ ((not compound or force_error|default(false)) and not valid ? ' is-invalid'))|trim})} %}{{ block('attributes') }}{% endwith %}> | ||
{%- if is_form_floating or is_input_group -%} | ||
<div class="{{ block('form_label_class') }}"></div> | ||
<div class="{{ block('form_group_class') }}"> | ||
{%- if is_form_floating -%} | ||
<div class="form-floating"> | ||
{{- form_widget(form, widget_attr) -}} | ||
{{- form_label(form) -}} | ||
</div> | ||
{%- elseif is_input_group -%} | ||
<div class="input-group"> | ||
{{- form_label(form) -}} | ||
{{- form_widget(form, widget_attr) -}} | ||
{#- Hack to properly display help with input group -#} | ||
{{- form_help(form) -}} | ||
</div> | ||
{%- endif -%} | ||
{%- if not is_input_group -%} | ||
{{- form_help(form) -}} | ||
{%- endif -%} | ||
{{- form_errors(form) -}} | ||
</div> | ||
{%- else -%} | ||
{{- form_label(form) -}} | ||
<div class="{{ block('form_group_class') }}"> | ||
{{- form_widget(form, widget_attr) -}} | ||
{{- form_help(form) -}} | ||
{{- form_errors(form) -}} | ||
</div> | ||
{%- endif -%} | ||
{##}</div> | ||
{%- endif -%} | ||
{%- endblock form_row %} | ||
|
||
{% block fieldset_form_row -%} | ||
{%- set widget_attr = {} -%} | ||
{%- if help is not empty -%} | ||
{%- set widget_attr = {attr: {'aria-describedby': id ~"_help"}} -%} | ||
{%- endif -%} | ||
<fieldset{% with {attr: row_attr|merge({class: row_attr.class|default('mb-3')|trim})} %}{{ block('attributes') }}{% endwith %}> | ||
<div class="row{% if (not compound or force_error|default(false)) and not valid %} is-invalid{% endif %}"> | ||
{{- form_label(form) -}} | ||
<div class="{{ block('form_group_class') }}"> | ||
{{- form_widget(form, widget_attr) -}} | ||
{{- form_help(form) -}} | ||
{{- form_errors(form) -}} | ||
</div> | ||
</div> | ||
</fieldset> | ||
{%- endblock fieldset_form_row %} | ||
|
||
{% block submit_row -%} | ||
<div{% with {attr: row_attr|merge({class: (row_attr.class|default('mb-3') ~ ' row')|trim})} %}{{ block('attributes') }}{% endwith %}>{#--#} | ||
<div class="{{ block('form_label_class') }}"></div>{#--#} | ||
<div class="{{ block('form_group_class') }}"> | ||
{{- form_widget(form) -}} | ||
</div>{#--#} | ||
</div> | ||
{%- endblock submit_row %} | ||
|
||
{% block reset_row -%} | ||
<div{% with {attr: row_attr|merge({class: (row_attr.class|default('mb-3') ~ ' row')|trim})} %}{{ block('attributes') }}{% endwith %}>{#--#} | ||
<div class="{{ block('form_label_class') }}"></div>{#--#} | ||
<div class="{{ block('form_group_class') }}"> | ||
{{- form_widget(form) -}} | ||
</div>{#--#} | ||
</div> | ||
{%- endblock reset_row %} | ||
|
||
{% block button_row -%} | ||
<div{% with {attr: row_attr|merge({class: (row_attr.class|default('mb-3') ~ ' row')|trim})} %}{{ block('attributes') }}{% endwith %}>{#--#} | ||
<div class="{{ block('form_label_class') }}"></div>{#--#} | ||
<div class="{{ block('form_group_class') }}"> | ||
{{- form_widget(form) -}} | ||
</div>{#--#} | ||
</div> | ||
{%- endblock button_row %} | ||
|
||
{% block checkbox_row -%} | ||
<div{% with {attr: row_attr|merge({class: (row_attr.class|default('mb-3') ~ ' row')|trim})} %}{{ block('attributes') }}{% endwith %}>{#--#} | ||
<div class="{{ block('form_label_class') }}"></div>{#--#} | ||
<div class="{{ block('form_group_class') }}"> | ||
{{- form_widget(form) -}} | ||
{{- form_help(form) -}} | ||
{{- form_errors(form) -}} | ||
</div>{#--#} | ||
</div> | ||
{%- endblock checkbox_row %} | ||
|
||
{% block form_group_class -%} | ||
col-sm-10 | ||
{%- endblock form_group_class %} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.