S
S
sadCake2020-05-26 18:26:30
symfony
sadCake, 2020-05-26 18:26:30

How to display a piece of html in edit SonataAdmin?

In list and show, you can pass null as the second argument in $formmapper->add and then specify template in the parameters where the field value (in this case, there is a model) from the first argument will be passed. But if you do this in configureFormFields, then it starts to swear that you need to set the type. I tried to create a custom fieldType, but I can't pass the template there. It takes some default value:

public function buildView(FormView $view, FormInterface $form, array $options)
    {
        $view->vars['template'] = $options['template'];
    }

    public function configureOptions(OptionsResolver $resolver)
    {
        $options = [];

        $resolver->setDefaults(array_merge($options, [
            'template' => '',
        ]));
    }


On a good note, I would like to understand how to correctly pass a template into this type so that the type pulls it up and I can further use it in the admin panel when I need to display some kind of template.
But I have already killed a few hours on this and I would like to know in general how you can display at least some piece of html in the edit form

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question