sonata-admin

symfony 2 sonataAdminBundle override template

荒凉一梦 提交于 2020-01-22 22:07:36
问题 how can we override sonata bundle layout for a single Admin class like i have created 3 Admin Class userAdmin, productAdmin, ticketAdmin now i want to override ticketAdmin edit action and edit template and add some extra code there. 回答1: If you don't want to create an extra controller you can use this method mentioned in the docs: Admin's documentation - Reference - Templates (master) - 20.6. Configuring templates services: sonata.admin.post: class: Acme\DemoBundle\Admin\PostAdmin tags: - {

symfony 2 sonataAdminBundle override template

核能气质少年 提交于 2020-01-22 22:05:14
问题 how can we override sonata bundle layout for a single Admin class like i have created 3 Admin Class userAdmin, productAdmin, ticketAdmin now i want to override ticketAdmin edit action and edit template and add some extra code there. 回答1: If you don't want to create an extra controller you can use this method mentioned in the docs: Admin's documentation - Reference - Templates (master) - 20.6. Configuring templates services: sonata.admin.post: class: Acme\DemoBundle\Admin\PostAdmin tags: - {

How to process each entity in SonataAdminBundle list view?

假如想象 提交于 2020-01-13 19:57:07
问题 How to apply some code to each entity being displayed in Admin's list view? For example, if I have a TagManager and need to load tags for each entity being displayed, how do I do that? Is there a method to override in entity's Admin or can I bind to some list form event? I could not find a place to do that. I don't wan't to bind to entity's onLoad event. 回答1: EDIT: In your entityAdminController : public function listAction() { if (false === $this->admin->isGranted('LIST')) { throw new

datagrid filter for relation object as text field (insted of dropdown) in sonata admin in symfony 2.4

蹲街弑〆低调 提交于 2020-01-12 19:00:13
问题 I have entity 'Action' with relation to 'User'. Created Admin CRUD controller in SonataAdminBundle. Everything works fine except user filter is rendered as dropdown list. I have 8k user count and growing so you must see why this is a problem. I want user filter to be text input and on submit to search with LIKE %username% Right now I add user filter like this - $datagridMapper->add('user') . I know I can add filter type and field type but I am not able to find the right combination and

datagrid filter for relation object as text field (insted of dropdown) in sonata admin in symfony 2.4

半世苍凉 提交于 2020-01-12 18:59:13
问题 I have entity 'Action' with relation to 'User'. Created Admin CRUD controller in SonataAdminBundle. Everything works fine except user filter is rendered as dropdown list. I have 8k user count and growing so you must see why this is a problem. I want user filter to be text input and on submit to search with LIKE %username% Right now I add user filter like this - $datagridMapper->add('user') . I know I can add filter type and field type but I am not able to find the right combination and

Sonata Admin search feature

有些话、适合烂在心里 提交于 2020-01-12 18:54:48
问题 I recently updated my symfony2 project vendors. Thus I got latest Sonata Admin Bundle version (updated from 2.2.5 to 2.2.6). I saw there is a new search feature in this release but I can't get it work. I can't figure out what I'm doing wrong. Drives me crazy. Here is my composer.json require : "require": { "php": ">=5.3.3", "symfony/symfony": "2.3.*", "doctrine/orm": ">=2.2.3,<2.4-dev", "doctrine/doctrine-bundle": "1.2.*", "twig/extensions": "1.0.*", "symfony/assetic-bundle": "2.3.*",

Is there any way to determine current action (create or edit) in Sonata\AdminBundle\Admin\Admin::configureFormFields()?

两盒软妹~` 提交于 2020-01-12 06:37:09
问题 I'd like to create different fields configuration for create and edit actions in Sonata Admin Bundle. Is there any way to determine it except checking $this->getSubject()->getId() in Sonata\AdminBundle\Admin\Admin::configureFormFields() ? 回答1: You can also do this: protected function configureFormFields(FormMapper $formMapper) { if ($this->isCurrentRoute('create')) { // CREATE } else { // EDIT } } 回答2: with: if($this->getRequest()->get($this->getIdParameter()) == null){ // create } else { //

How to install SonataDoctrineMongoDBAdminBundle properly?

核能气质少年 提交于 2020-01-12 03:41:08
问题 I am really getting nervous because of lacking of enough resource for installing SonataDoctrineMongoDBAdminBundle and it's dependencies like sonataUserBundle. I have been trying to install this bundle for 15 days. I did everyting agaian and again what telling in sonata's official page. But it does not work properly. After extending sonataUserBundle as ApplicationUserBundle my final documents are: User.php <?php /** * This file is part of the <name> project. * * (c) <yourname> <youremail> * *

Symfony2 Sonata Admin show attribute only as a readyonly text

假如想象 提交于 2020-01-12 03:31:09
问题 I have some immutable attributes on my entity to administrate with sonata-admin bundle. I want to show them in the edit-view of the entity, but don't want to provide any mechanism to change it (e.g. the value shall not be inside a input field) I couldn't find anything but this: $formMapper ->add('post', 'entity', array( 'label' => 'Some post', 'attr' => array( 'readonly' => true, 'disabled' => true ), 'class' => 'Acme\DemoBundle\Entity\Post' ) ) ; I tried it out with read_only , readonly ,

Format for time display?

自古美人都是妖i 提交于 2020-01-11 08:18:35
问题 I am making application with symfony2 and sonata-admin bundle. public function configureListFields(ListMapper $listMapper) { $listMapper ->addIdentifier('id') ->add('fromDate'); it shows time like this September 1, 2013 02:00 so I changed - ->add('fromDate'); + ->add('fromDate',null,array('format' => 'yyyy-MM-dd HH:mm:ss')) but it still show the same. please give me how to use format for time display? 回答1: Try using ->add('fromDate','datetime',array('date_format' => 'yyyy-MM-dd HH:mm:ss')) By