Easyadminbundle: Variable "easyadmin" does not exist in @EasyAdmin/form/bootstrap_3_layout.html.twig

Created on 8 Nov 2016  路  6Comments  路  Source: EasyCorp/EasyAdminBundle

Hello
I'm getting the Exception since easyadmin-bundle 1.15.2 (my symfony/symfony version is 3.1.6):

Variable "easyadmin" does not exist in @EasyAdmin/form/bootstrap_3_layout.html.twig at line 356.
Line 356 corresponds with the include clause here:

{% block empty_collection %}
    <div class="empty collection-empty">
        {{ include(easyadmin.entity.templates.label_empty) }}
    </div>
{% endblock empty_collection %}

Thanks in advance.


Previous error is being triggered by using the form_widget_compound. Does anybody knows how to prevent Symfony from using the 'form_widget_compound', and using the 'form_widget_simple' instead? The form is generated in a Controller:

/* Entity retrieval, etc */
$form = $this->createFormBuilder()
    ->add('old_password', PasswordType::class)
    ->add('new_password', PasswordType::class)
    ->add('confirm_new_password', PasswordType::class)
    ->add('save', SubmitType::class, array('label' => 'Confirm'))
    ->getForm();

return $this->render('default/multipurpose_form.html.twig', array(
    'title' => "Change password",
    'entity' => $entity,
    'form' => $form->createView(),
    'response' => $serviceResponse
));

I am aware that this is a Symfony Forms related question, but any kind of information is appreciated.

Thanks people

bug

Most helpful comment

Hello,
Sorry for the slow feedback, I had to leave this. Thanks for the answers and the #1376 research.
I solved the stuff removing the line in my custom template:

{% form_theme form with easyadmin_config('design.form_theme') %}

The point was just to keep EasyAdmin form styles when using a custom form set up from a Controller. The strange thing is that the entity (User) is mapped in the easyadmin.yml. So I guess the only thing to discuss here is if there's any way to "hack" the EasyAdmin vars container in some way, in order to set missing easyadmin config dimensions, or a more acceptable way to use EasyAdmin form styles.

All 6 comments

Thanks for reporting this error. I'm afraid that I don't know what's going on because this goes beyond my limited Symfony Forms knowledge. In any case, I propose a simple solution to this issue in #1376.

Is this code from a custom action ?

You're probably using the easyadmin form theme with your own form, which is probably wrong because the easyadmin variable is injected in form views by a dedicated form type extension, expecting the easyadmin in the request attributes.
But this request attribute only exists for easyadmin base actions (and custom ones using the method based actions IIRC).
So if you're in a custom route based action, the variable does not exists (and actually it won't make sense to use this form theme without this variable. The whole form theme should probably only be used with the EasyAdminFormType).

Let's close this issue for now ... and we'll reopen if there is more information/details from the reporter. Thanks!

Hello,
Sorry for the slow feedback, I had to leave this. Thanks for the answers and the #1376 research.
I solved the stuff removing the line in my custom template:

{% form_theme form with easyadmin_config('design.form_theme') %}

The point was just to keep EasyAdmin form styles when using a custom form set up from a Controller. The strange thing is that the entity (User) is mapped in the easyadmin.yml. So I guess the only thing to discuss here is if there's any way to "hack" the EasyAdmin vars container in some way, in order to set missing easyadmin config dimensions, or a more acceptable way to use EasyAdmin form styles.

Same error:
Variable "easyadmin" does not exist.
in vendor\easycorpeasyadmin-bundle\src\Resources\views\form\bootstrap_3_layout.html.twig (line 255)

With easyAdminBundle v1.17.13

When add a ChoiceType only with:
'expanded' => true,
'multiple' => false,
in a formType

'expanded' => false,
'multiple' => false,
[OK]

Getting same error

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tamert picture tamert  路  3Comments

BigMichi1 picture BigMichi1  路  3Comments

lukasluecke picture lukasluecke  路  3Comments

SirMishaa picture SirMishaa  路  3Comments

devkbsc picture devkbsc  路  3Comments