symfony-sonata

How can I create a custom DataGrid filter in SonataAdmin

安稳与你 提交于 2019-12-31 16:51:44
问题 I have an entity Transaction with numerous status codes. I want the user to be able to see these status codes as strings in SonataAdmin. The user should also be able to filter on the basis of these status codes. Entity Transaction { const TRANSACTION_STATUS_WAITING = 1; const TRANSACTION_STATUS_PENDING = 2; const TRANSACTION_STATUS_CONFIRMED = 3; /** * Set status * * @param smallint $status */ public function setStatus($status) { $this->status = $status; } /** * Get status * * @return

Add constraints in upload image : SonataMediaBundle

烂漫一生 提交于 2019-12-24 07:16:53
问题 How can I add constraints to upload an image, for example : max size, error message, there is not thing about that in the config of sonata_media. thank you very much. 回答1: First you will use the CompilerPassInterface component to override the SonataMediaBundle's MediaAdmin class as per link: Overriding the part of bundle supose you are in AcmeDemoBundle: <?php namespace Acme\DemoBundle\DependencyInjection; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony

SonataAdmin custom form action

£可爱£侵袭症+ 提交于 2019-12-24 05:56:50
问题 I am using SonataAdminBundle and I'd like to know how to add a custom form action in the edit (Something similar to the Save, Update and Close ) There doesn't seem to anything documented about it. I'm trying to add a custom input field that will call a controller or something to update a value and send an email Is there any docs or examples on how to do this? Thanks 回答1: You can add custom form actions by adding new routes. Because when you add new route you need also add action to handle

Sonata Media Bundle remove gallery

ぃ、小莉子 提交于 2019-12-23 21:14:16
问题 I have the Sonata Media Bundle installed but I don't use the gallery portion of the bundle. How do I disable the Gallery? I am using Symfony 2.3 and I have the standard Media Bundle install as per the documentation. Solution thus far: If you look at this issue https://github.com/sonata-project/SonataAdminBundle/issues/460 from the admin bundle you can disable a admin by adding the show_in_dashboard: false tag to the yaml file. To do this I simply add my own compiler that adds this flag for me

No thumbnails generated

随声附和 提交于 2019-12-23 12:11:51
问题 I am using Sonata Media Bundle with Symfony2.3 in my project. When I override youtube provider sonata.media.provider.youtube . Everything working fine. No errors or anything but in /Web/uploads/media no thumbnails generated but in my admin dashboard show me : /uploads/media/default/0001/01/thumb_9_default_small.jpg. I don't know how but when I am not override sonata.media.provider.youtube then thumbnails generated in /web/uploads/media/ Like : /web/uploads/media/default/0001/01/thumb_9

Sonata admin enhanced view for security roles

落花浮王杯 提交于 2019-12-23 04:45:46
问题 In sonata admin the roles are based on admin services name with CRUD export and master permissions but the way it looks not so user friendly to create groups for others user or assign specific permissions to a user considering an example for sonata admin post module the service for admin is named as sonata.news.admin.post and for that service generated roles will look like ROLE_SONATA_NEWS_ADMIN_POST_EDIT ROLE_SONATA_NEWS_ADMIN_POST_LIST ROLE_SONATA_NEWS_ADMIN_POST_CREATE ROLE_SONATA_NEWS

Exporting one to many relationship on sonata admin

情到浓时终转凉″ 提交于 2019-12-22 07:13:12
问题 I have tried to search online for a definite solution to this question but there's really no concrete solution for newbies out there. I have an Entry which has many EntryListing. In my EntryAdmin listMapper, i comfortably can list entries by a statement as simple as ->add('listings') which simply returns the listings as defined in the EntryListing __toString() function. Is there a way to achieve the same when exporting the data by overiding the getExportFields() functions as below: public

Nested collection fields in Sonata Admin (2.3)

ε祈祈猫儿з 提交于 2019-12-20 16:46:49
问题 I'm having problems creating my form for creating a course. This is a part of my database scheme for which I'm trying to create a form: So which I'm trying to do is create a course where I can create sessions and dates (moment) attached to that session. It should look something like this: In my CourseAdmin class I have: protected function configureFormFields(FormMapper $formMapper) { $formMapper ->add('name', 'text', array('label' => 'Naam')) ->add('description', 'textarea', array('label' =>

show/hide some menus depend on the Sonata admin ROLE

依然范特西╮ 提交于 2019-12-19 04:04:09
问题 I'm working on a web project using Symfony2 , and i used Sonata Admin for the admin Panel , every thing works fine but what i want to do is ,on the dashboard menus of sonata Admin , i need to show hide some menus depend on the admin ROLE , so did any one do this before or know how to do it ? i tryed to use the config of the roles but when i'm connecting with a ROlE diffrent of ROLE_SONATA_ADMIN the top menu dont show up , - { path: ^/admin, role: [ROLE_ADMIN, ROLE_SONATA_ADMIN,ROLE_ADMIN_NEWS

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