-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Feedback required] Fixed asset version strategy #15108
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
Not sure why the tests are failing. |
Can you add some tests to avoid regressions? |
This seems impossible to fix. framework:
assets:
assets_version: %app_version%
assets_version_format: "%%s?v=%%s"
packages:
foo:
version: ~
version_format: ~
bar:
base_urls: [] Both packages will have version value |
It's a bit more difficult to fix as the behaviour changed slightly with the new Asset component. I'll take a look into this. |
@xabbuh That would be nice! |
Any news on this one? |
Didn't find the time to fix it. I hope to manage it some time the next days. |
Any updates? @xabbuh |
$version = $this->createVersion($container, $package['version'], $format, $name); | ||
} | ||
$format = $package['version_format'] ?: $config['version_format']; | ||
$version = $this->createVersion($container, $package['version'], $format, $name); |
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.
you are changing the behavior of null
here
Closing this PR as it cannot be merged as is and we have an issue that references the issue, so it's not lost. |
…ino) This PR was squashed before being merged into the 5.3-dev branch. Discussion ---------- [Form] Add "form_attr" FormType option | Q | A | ------------- | --- | Branch? | 5.x | Bug fix? |no | New feature? | yes | Deprecations? | no | Tickets | N/A | License | MIT | Doc PR | [#15108](symfony/symfony-docs#15108) ## What is this about This PR add support for [`form` attribute](https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#attr-fae-form) to Symfony Form ([browser compatibility](https://caniuse.com/form-attribute)). The `form` attribute allows form elements to override their associated form (which is their nearest ancestor form element by default). This is extremely useful to solve **nested form problem** and allows **form children** to be **rendered outside form tag** while still working as expected. ## New "form_attr" FormType option #### form_attr **type**: `bool` or `string` **default**: `false` If set to `true` on a **root form**, adds [`form` attribute](https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#attr-fae-form) on every children with their root **form id**. This allows you to render form children outside the form tag and avoid **nested form problem** in some situations while keeping the form working properly. If set to `true` on a **child**, adds [`form` attribute](https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#attr-fae-form) on it with its **root form id**. This allows you to render **that child** outside the form tag and avoid **nested form problem** in some situations while keeping the form working properly. If root form has no `id` (this may happen by create an *unnamed* form), you can set it to a `string` identifier to be used at `FormView` level to link children and root form anyway. ## Usage on Root Form Example #### Form Type Enable the feature by setting `form_attr` to `true` on the root form. ```php use Symfony\Component\Form\Extension\Core\Type; class ListFilterType extends AbstractType { public function buildForm(FormBuilderInterface $builder, array $options): void { $builder ->add('search', Type\SearchType::class) ->add('orderBy', Type\ChoiceType::class, [ 'choices' => [ // ... ], ]) ->add('perPage', Type\ChoiceType::class, [ 'choices' => [ // ... ], ]) } public function configureOptions(OptionsResolver $resolver): void { $resolver->setDefault('form_attr', true); // <--- Set this to true } } ``` #### Twig The following Twig template **works properly** even if form children are **outside** their form tag ([browser compatibility](https://caniuse.com/form-attribute)). ```twig <div class="header-filters"> {{ form_errors(form) }} {{ form_row(form.search) }} {# has attribute form="list_filter" #} {{ form_row(form.orderBy) }} {# has attribute form="list_filter" #} </div> <!-- --> <!-- Some other HTML content, like a table or even another Symfony form --> <!-- --> <div class="footer-filters"> {{ form_row(form.perPage) }} {# has attribute form="list_filter" #} </div> {{ form_start(form) }} {# id="list_filter" #} {{ form_end(form) }} ``` ✅ Every form elements work properly even outside form tag. ## Usage on Form Child Example Enable the feature by setting `form_attr` to `true` on selected child. ```php use Symfony\Component\Form\Extension\Core\Type; class ListFilterType extends AbstractType { public function buildForm(FormBuilderInterface $builder, array $options): void { $builder ->add('search', Type\SearchType::class) ->add('orderBy', Type\ChoiceType::class, [ 'choices' => [ // ... ], ]) ->add('perPage', Type\ChoiceType::class, [ 'form_attr' => true, // <--- Set this to true 'choices' => [ // ... ], ]) } } ``` #### Twig The following Twig template **works properly** even if `form.perPage` is **outside** form tag ([browser compatibility](https://caniuse.com/form-attribute)). ```twig <div class="header-filters"> {{ form_start(form) }} {# id="list_filter" #} {{ form_errors(form) }} {{ form_row(form.search) }} {{ form_row(form.orderBy) }} {{ form_end(form, {'render_rest': false}) }} </div> <!-- --> <!-- Some other HTML content, like a table or even another Symfony form --> <!-- --> <div class="footer-filters"> {{ form_row(form.perPage) }} {# has attribute form="list_filter" #} </div> ``` ✅ `form.perPage` element work properly even outside form tag. Commits ------- 5f913ce [Form] Add "form_attr" FormType option
EmptyVersionStrategy is completely ignored since Symfony 2.7 due to a string cast.