sonata-admin

custom action in SonataAdminBundle

空扰寡人 提交于 2019-12-18 10:57:30
问题 On this page I found how to add route for my custom action. protected function configureRoutes(RouteCollection $collection) { $collection->add('ispremium', $this->getRouterIdParameter().'/ispremium'); } After that I add custom action in my Admin class: protected function configureListFields(ListMapper $listMapper) { $listMapper ->addIdentifier('id') ->add('code', null, array('label' => 'Code')) ->add('_action', 'actions', array( 'actions' => array( 'ispremium' => array( 'template' =>

SonataAdminBundle custom rendering of text fields in list

荒凉一梦 提交于 2019-12-17 18:11:43
问题 I'm using symfony2 and SonataAdminBundle. I have a simple Entity called Post in which I have content field that is basically html text (from a ckeditor for the record). I need to display in the Post list the content field as raw html, without escaping it. Hacking base_list_field template like this {% block field %}{{ value|raw }}{% endblock %} works, but it's clearly not the proper way. Any hints? edit: SOLVED! I've defined a custom html type in the config.yml for sonata_doctrine_orm_admin:

SonataAdminBundle : display non crud (statistics)

江枫思渺然 提交于 2019-12-17 17:28:59
问题 I'm using sonata admin bundle to generate my backend, I'm so happy with it that I would like to use my backend to display statistics as well. I guess I can do that by tweaking bundle's views, "standard_layout.html.twig" maybe. Problem is, I can't find examples or even people speaking about it, so I'm wondering, is that possible ? Aren't people speaking about it because it's too simple ? Did you do it ? I really would like to have a single backend, so pls enlighten me ! Thank you, copndz 回答1:

Disable CSRF protection in form generated by Sonata Admin

纵然是瞬间 提交于 2019-12-14 03:21:43
问题 In Sonata Admin I need to disable the CSRF token in some of my forms but sometimes I don't want to create a Form Type class, choosing instead to let Sonata generate the form, as such: /** @var $form \Symfony\Component\Form\Form */ $form = $this->admin->getForm(); How can I disable the CSRF token from this point? 回答1: Without a Form Type class, the best way to change the CSRF field would be in the admin Class. For that, it's possible to override this function: public function getFormBuilder()

Sonata Admin - Custom AJAX call

蓝咒 提交于 2019-12-14 03:14:05
问题 I have created a custom list view in sonata admin to display a calendar. I'm trying to add events to the calendar dynamically, but I'm getting an error with the CSRF token being invalid. I have the following code: public function listAction() { if (false === $this->admin->isGranted('LIST')) { throw new AccessDeniedException(); } $datagrid = $this->admin->getDatagrid(); $formView = $datagrid->getForm()->createView(); // set the theme for the current Admin Form $this->get('twig')->getExtension(

Sonata media validation at admin

末鹿安然 提交于 2019-12-14 00:27:57
问题 I'm trying to validate image. I saw answer at Sonata Media: The file could not be found How to validate image (width and height). I need help on that. There is no proper doc in net. 回答1: To validate image dimensions using sonata media you need to override sonata media's ImageProvider class, sonata uses this class to handle image manipulation.If you already have an extended bundle of sonata media bundle then in services.yml file you can define your own provider as below ,make sure your yml

Symfony2 Sonata: No Entity Manager in Custom Class

百般思念 提交于 2019-12-13 21:35:06
问题 I'm trying to create custom Form in Sonata-Admin and Im geting No entity manager defined for class School\ChildBirthBundle\Entity\DataChapter My code: namespace School\ChildBirthBundle\Admin; 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 Knp\Menu\ItemInterface as MenuItemInterface; use School\ChildBirthBundle\Entity\DataChapter;

oneToMany relation entity does not save id field

孤者浪人 提交于 2019-12-13 17:24:30
问题 I'm trying to manage a oneToMany relation with sonata admin Actually I'd like to have manyToMany relation like sonata media bundle has with gallery > media A HomePage has many Story s which should be sortable etc. Theres also HomePageStory to manage the relation, as suggested here: https://github.com/sonata-project/SonataAdminBundle/issues/1231 HomePage.orm.yml oneToMany: HomePageStorys: targetEntity: HomePageStory mappedBy: HomePage cascade: ["persist", "merge", "remove"] HomePageAdmin.php -

Symfony2 SonataAdminBundle Password field encryption

社会主义新天地 提交于 2019-12-13 14:26:59
问题 I have FOSUserBundle to manage my users, and SonataAdminBundle to manage my website... I have a problem, whenever I try to change/add a password to any user, the password isn't encoded into sha512 , but it does when the user register itself inside fosuserbundle registration page... So there isn't any problem with Symfony2 configuration neither fosuserbundle config, it may be inside SonataAdminBundle somewhere, or maybe into my admin class... <?php // src/Acme/DemoBundle/Admin/PostAdmin.php

Symfony 2.3.6 and Sonata Admin Bundle : Empty dashboard and no errors

岁酱吖の 提交于 2019-12-13 14:12:03
问题 I've been looking for what is going wrong for days now; I followed the documentation from the sonata website and repeated it several times, but my dashboard is still empty. After writing my AdminClass and Services (and setup the config.yml ), I regenerate entities and updated my schema, but Sonata created a table in my DB for entities that I wanted to be in admin . Here is my code for App/Config/Config.yml ( top of file for imports ) imports: - { resource: parameters.yml } - { resource: