Skip to content

Commit

Permalink
Restore form theme template
Browse files Browse the repository at this point in the history
  • Loading branch information
norkunas committed Oct 5, 2023
1 parent 54d36cc commit 05e47bc
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ final class AutocompleteExtension extends Extension implements PrependExtensionI
{
public function prepend(ContainerBuilder $container)
{
$bundles = $container->getParameter('kernel.bundles');

if (isset($bundles['TwigBundle'])) {
$container->prependExtensionConfig('twig', [
'form_themes' => ['@Autocomplete/autocomplete_form_theme.html.twig'],
]);
}

if ($this->isAssetMapperAvailable($container)) {
$container->prependExtensionConfig('framework', [
'asset_mapper' => [
Expand Down
15 changes: 15 additions & 0 deletions src/Autocomplete/templates/autocomplete_form_theme.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{# EasyAdminAutocomplete form type #}
{% block ux_entity_autocomplete_widget %}
{% if form.autocomplete is defined %}
{{ form_widget(form.autocomplete, { attr: form.autocomplete.vars.attr|merge({ required: required }) }) }}
{% else %}
{{ form_widget(form) }}
{% endif %}
{% endblock ux_entity_autocomplete_widget %}

{% block ux_entity_autocomplete_label %}
{% if form.autocomplete is defined %}
{% set id = form.autocomplete.vars.id %}
{% endif %}
{{ block('form_label') }}
{% endblock ux_entity_autocomplete_label %}

0 comments on commit 05e47bc

Please sign in to comment.