How to remove default add button

2,135 views
Skip to first unread message

Thomas Gilbert

unread,
Jan 18, 2012, 9:10:45 AM1/18/12
to sonata-users
Hi,

I try to remove the add button in the list or
the edition. And remove button from the edition.

It must be configured from the dahboard or class ?

Thomas Rabaix

unread,
Jan 18, 2012, 9:25:46 AM1/18/12
to sonata...@googlegroups.com
If you want to remove the feature from the admin, you need to remove the route

configureRoute(RouteCollection $collection) {
  $collection->remove('edit');
}

If you want to remove the feature per user you need to use permission.



--
You received this message because you are subscribed to the Google Groups "sonata-users" group.
To post to this group, send email to sonata...@googlegroups.com.
To unsubscribe from this group, send email to sonata-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/sonata-users?hl=en.




--
Thomas Rabaix
http://rabaix.net | http://sonata-project.org

Thomas Gilbert

unread,
Jan 18, 2012, 9:42:50 AM1/18/12
to sonata-users

Thanks

It works

protected function configureRoutes(RouteCollection $collection)
{
$collection->remove('create');
}



On 18 jan, 15:25, Thomas Rabaix <tho...@rabaix.net> wrote:
> If you want to remove the feature from the admin, you need to remove the
> route
>
> configureRoute(RouteCollection $collection) {
>   $collection->remove('edit');
>
> }
>
> If you want to remove the feature per user you need to use permission.
>

David Romaní

unread,
Aug 19, 2014, 7:01:41 AM8/19/14
to sonata...@googlegroups.com, tho...@rabaix.net
I have a problem with remove batch route and Sonata User Bundle.

· Admin Class:

namespace Application\Sonata\UserBundle\Admin\Model;

use Sonata\AdminBundle\Admin\Admin;
use Sonata\AdminBundle\Form\FormMapper;
use Sonata\AdminBundle\Datagrid\DatagridMapper;
use Sonata\AdminBundle\Datagrid\ListMapper;
use Sonata\AdminBundle\Show\ShowMapper;
use Sonata\AdminBundle\Route\RouteCollection;
use FOS\UserBundle\Model\UserManagerInterface;

class UserAdmin extends Admin
{
    protected $userManager;

    // Base admin route pattern
    protected $baseRoutePattern = 'user';

    protected function configureRoutes(RouteCollection $collection)
    {
        $collection->remove('batch');
    }

   (...)
}

But when rendering users list view I have got this error:

An exception has been thrown during the rendering of a template ("Unable to generate a URL for the named route "admin_sonata_user_user_batch" as such route does not exist.") in SonataAdminBundle:CRUD:base_list.html.twig at line 35.


I don't understant why {% if admin.hasRoute('batch') %} equals to true in SonataAdminBundle:CRUD:base_list.html.twig line 34. Can you help me, please?



El dimecres 18 de gener de 2012 15:25:46 UTC+1, Thomas Rabaix va escriure:

Cassiano Tartari

unread,
Aug 19, 2014, 7:31:06 AM8/19/14
to sonata-users, Thom as
Can you see the route running:

php app/console route:dump |grep batch


Cassiano Valle Tartari
MSc. Computer Engineer

Tel: +55.48.84474818
Email: fal...@cassianotartari.eng.br
Site: http://www.cassianotartari.eng.br

QR Code


To unsubscribe from this group and stop receiving emails from it, send an email to sonata-users...@googlegroups.com.

To post to this group, send email to sonata...@googlegroups.com.

David Romaní

unread,
Aug 19, 2014, 7:45:16 AM8/19/14
to sonata...@googlegroups.com, tho...@rabaix.net
No, batch route is not listed inside route dump.

Piotr Galas

unread,
Aug 22, 2014, 1:36:02 AM8/22/14
to sonata...@googlegroups.com, tho...@rabaix.net
This error ocure because you remove bath route and you still use this route in your twig file at line 35. If you remove some routes you cant use it in twig.

David Romaní

unread,
Aug 22, 2014, 3:24:47 AM8/22/14
to sonata...@googlegroups.com, tho...@rabaix.net
Hello Piotr,

This is true and this is the reason about you can see in template this line to avoid disabled routes:

{# SonataAdminBundle:CRUD:base_list.html.twig line 34 #}

{% if admin.hasRoute('batch') %}

Fortunately, the problem has been disappeared (I don't know how...)

Thanks for your time

Louis Bourguignon

unread,
Nov 16, 2015, 7:18:52 AM11/16/15
to sonata-users, tho...@rabaix.net
Hello,

I had the same issue. I solved it by clearing Symfony cache (cache:clear).

Strange..
Reply all
Reply to author
Forward
0 new messages