Use Bootstrap static control from inside form #290
Merged
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.
Convenience stuff to define BS static form controls inside the forms creation.
This could of course all be done with fiddling in the template, rendering the form row-wise and using the twig
form_control_static()
function, but i'm often in the need to display one or more fields from my entity as static controls, and this let me do a simple{{ form(form, {'style': 'horizontal'}) }}
in the template.This patch consists of two commits which are independent from each other, just provide different ways and usages:
Extension
Provides for all fields which are rendered as
form_widget_simple
(date, time, datetime with'widget' => 'single_text'
set, number, integer, url, email) to be rendered as static control, using :You should always set the field type explicitly instead of using autoguessing, which leads sometimes to extra attributes in the markup (eg
maxlength
) that break html validation.Static control field type
Just another way to get a 'static control' rendered in the form:
I'm not sure which one is the best to use, as both have advantages. Maybe just take both:)
And sorry for not providing tests, i still need to learn/understand that mockup stuff