Selaa lähdekoodia

Add note for actions rendered directly into a template. (#4201)

Mentos93 8 vuotta sitten
vanhempi
commit
cb5a560043
1 muutettua tiedostoa jossa 11 lisäystä ja 0 poistoa
  1. 11 0
      Resources/doc/cookbook/recipe_custom_action.rst

+ 11 - 0
Resources/doc/cookbook/recipe_custom_action.rst

@@ -257,3 +257,14 @@ The full ``CarAdmin.php`` example looks like this:
             // ...
         }
     }
+
+.. note::
+
+    If you want to render a custom controller action in a template by using the
+    render function in twig you need to add ``_sonata_admin`` as an attribute. For
+    example; ``{{ render(controller('AppBundle:XxxxCRUD:comment', {'_sonata_admin':
+    'sonata.admin.xxxx' })) }}``. This has to be done because the moment the
+    rendering should happen the routing, which usually sets the value of this
+    parameter, is not involved at all, and then you will get an error "There is no
+    _sonata_admin defined for the controller
+    AppBundle\Controller\XxxxCRUDController and the current route ' '."