-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Allow for the theming of specific fields within a collection type #2806
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
Conversation
Can you also update the CHANGELOG? |
foreach($view->getChildren() as $rowName => $rowView) { | ||
foreach($rowView->getChildren() as $fieldName => $fieldView) { | ||
$rowTypes = $form->get($rowName)->getTypes(); | ||
$rowTypeName = $rowTypes[count($rowTypes) - 1]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be move to the outer loop
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thx, fixed
@fabpot: done also refactored, added a test and rebased onto master |
@stof done |
@vicb is it mergeable as is or is there something else to change ? you know the form theming better than me. |
I am not sure if playing with the |
Hi, What about this patch? Is it merged anywhere? Is there any other way having custom templating for fields inside a CollectionType? Thanks |
Updated to be up to date with 2.1 (and it appeared to be broken as some later changes went missing) I'm thinking about exactly what we want to be able to reference how. This PR only sets an extra type name for children of collection children, e.g. Suggestions:
children of children in collections:
|
Commits ------- 69e5e58 [Form] Individual rows of CollectionType cannot be styled anymore for performance reasons Discussion ---------- [Form] Individual rows of CollectionType cannot be styled anymore Bug fix: no Feature addition: no Backwards compatibility break: **yes** Symfony2 tests pass: yes Fixes the following tickets: #2806, #4733 Todo: - Individual theming of blocks in a row of a collection form is now unsupported: ``` {% block _author_tags_0_label %} {# ... #} {% endblock %} {% block _author_tags_1_label %} {# ... #} {% endblock %} ``` Instead, it is now possible to define a generic template for all rows, where the word "entry" replaces the previous occurence of the row index: ``` {% block _author_tags_entry_label %} {# ... #} {% endblock %} ``` The main motivation for this change is performance. Looking up whether individual styles exist for each single block within each row costs a lot of time. Because the row index is included in the block names, caching is virtually impossible. For [this specific, heavy form](http://advancedform.gpserver.dk/app_dev.php/taxclasses/1), this PR decreases rendering time from **7.7** to **2.5 seconds** on my machine. --------------------------------------------------------------------------- by fabpot at 2012-07-14T10:55:29Z @bschussek Can you also create a PR on symfony docs to update the documentation?
Bug fix: no
Feature addition: yes
Backwards compatibility break: no
Symfony2 tests pass: yes
At this moment it is not possible to theme fields in a collection form using blocks, other than:
{% _form_name_0_fieldname_widget %}
0 begin the row index.
This patch adds the name of the type within the collection type to the list of types which allows overriding:
{% _nameofrowtype_fieldname_widget %}