Hi,

I would like to add a button in screen of CRUD corresponding to edit. I am 
using the following:

src/Acme/DemoBundle/Admin/EntityAdmin.php:

protected function configureRoutes(\Sonata\AdminBundle\Route\RouteCollection 
$collection){
    $collection
        ->add('button_1',
            'button_1/{id}',
            array('_controller' => 'AcmeDemoBundle:Default:button_1'),
            array('id' => '\d+')
        )
    ;}

src/Acme/HelloBundle/Controller/DefaultController.php:

/**
    @Route("/button_1/{id}", name="button_1",
        requirements={"id" = "\d+"}
    )
    @Template("AcmeDemoBundle:Default:button_1.html.twig")
*/public function button_1Action($id)
{
    return(array(
        'id' => $id
    ));}

app/Resources/SonataAdminBundle/views/CRUD/base_edit_form.html.twig:

{% block form %}
    ...
    {% else %}
        ...
        {% block formactions %}
            ...
            {% else %}
                ...
                {% if admin.id(object) %}
                    ...
                    {% if admin.hasroute('button_1') %}
                        <a class="btn" target="_blank" href="{{ 
admin.generateObjectUrl('button_1', object) }}">{% trans from 
'SonataAdminBundle' %}link_button_1{% endtrans %}</a>
                    {% endif %}
                    ...


But the button doesnt't appear and the controller doesn't called. What 
would be the correct way to do this action, please?

Thanks,
Aline.

-- 
You received this message because you are subscribed to the Google Groups 
"sonata-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sonata-users.
For more options, visit https://groups.google.com/d/optout.

Reply via email to