Hi Mike,

And welcome to using Sonata Admin, I think you'll find it very powerful the 
more you learn of it. Like you, when first using Sonata I was very 
frustrated so I'll try to answer your questions without digging too deep, I 
strongly recommend reading every single line of the manual again and again 
and experiment to get the most out of it; until the reference gets 
upgraded, that's the best approach.
 

> Now, what I don't understand is how do I easily add custom logic. How can 
> I add logic so that different user roles can perform different actions on 
> an entity.
>

In Sonata, this comes under the banner of custom admin action, more details 
https://sonata-project.org/bundles/admin/master/doc/cookbook/recipe_custom_action.html
In essence:

   - Create a new controller, like the guide lets call it CRUDController
   - In your admin config definition, pass this controller as third argument
   - Create a twig snippet to show an action button which uses the route in 
   the new controller you created
   - Add the aforementioned action button to the listmapper
   - 
>    
>    Use the following namespace in your admin
>    
>    use Sonata\AdminBundle\Route\RouteCollection; 
>    
>    
With regard to adding a form to the show action, there are a couple of 
steps you will need to take

   - Override the default show template with your own, see 
   
https://sonata-project.org/bundles/admin/master/doc/reference/action_show.html#setting-up-a-custom-show-template-very-useful
   - Similar to how CRUDController was injected, create a controller which 
   as a method name has showAction
   - At that point, Sonata will be using your controller instead of the 
   native one. Look in the Sonata Vendor bundle at the following namespace for 
   the code you should copy Sonata\AdminBundle\Controller\CRUDController
   - With the normal controller present, add your form in like you would 
   any other Symfony form

I hope this helps you out, stick with it though. Sonata Admin is really 
worth it once you pass the initial frustration, I almost binned it so many 
times!

-- 
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