symfony-sonata

sonata admin custom list field (not from entity)

戏子无情 提交于 2019-12-05 04:59:01
问题 Sonata admin bundle documentation seems scarce and I did not find a way implement this. Goal: display boolean value in field list. Value should calculated for each object from other properties. I managed to implement this for datagridFilter as doctrine_orm_callback but not for listFields. Working code for configureDatagridFilters() : // LicenceAdmin.php protected function configureDatagridFilters(DatagridMapper $datagridMapper) { $datagridMapper->add('isValid', 'doctrine_orm_callback', [

Adding a custom form inside the show template of a Sonata Admin Entity

我与影子孤独终老i 提交于 2019-12-05 02:50:10
I want to generate a small form inside a Sonata Admin show template. What I have done so far is creating the function in the custom CRUD for that specific entity (order) that extends from Sonata's default CRUD; public function approveOrderAction($id = null) { $request = $this->getRequest(); $id = $request->get($this->admin->getIdParameter()); $order = $this->admin->getObject($id); $approveForm = $this->createFormBuilder($order) ->add('reqSecondApprover', 'checkbox', array('label' => 'Require second Approval', 'required' => false)) ->add('secondApprover', 'choice', array('choices' => Crud:

Sonata Media Bundle - how to write custom provider?

余生颓废 提交于 2019-12-05 02:15:16
问题 There is an example in the official documentation about how to write custom provider, but it doesn't work. My question is: what is the best way to write custom provider, especially how to write and register provider as a new service? When I try to use this code from documentation, I get errors about type of arguments. What does mean empty argument? Thank you. 回答1: After some investigation, the following code works: Register provider as a service: // src/Application/Sonata/MediaBundle

Overriding the User Admin Form

做~自己de王妃 提交于 2019-12-05 00:47:47
问题 I'm trying to override the SonataUser/Admin/Model/UserAdmin 's configureFormFields() because I need to remove some default fields from the admin form. So I have copied the file vendor/bundles/Sonata/UserBundle/Admin/Model/UserAdmin.php in my bundle app/Application/Sonata/UserBundle/Admin/Model/UserAdmin.php and modified it. Then declared it as a service: # app/application/Sonata/UserBundle/Resources/config/services.yml services: application_user.registration.form.type: class: Application

Sonata Admin Dashboard: configure actions per entity

非 Y 不嫁゛ 提交于 2019-12-05 00:34:28
问题 I'm using the SonataAdminBundle as base for an administration interface for a Symfony2 (v2.0.x) powered website. Entities which are added to the dashboard in SonataAdmin have the following actions by default: add list This works fine for most entities, however the website has a few entities for which data is not added via the admin interface - i.e. they are entered from the public facing website. Administrators only need to view them ("list" action in dashboard), edit them or delete them.

Symfony SonataAdmin Templates

我们两清 提交于 2019-12-04 20:01:45
I am trying to modify the SonataAdmin templates. I have an Image entity that has a path property. I created an ImageAdmin class and this is integrated into sonataAdmin. I would like to modify the admin-list-view to wrap the path in an img tag so that the image is actually displayed. Does anyone know how I can do this? Thanks! There are 2 ways to use your own templates. In the config file: sonata_doctrine_orm_admin: entity_manager: templates: form: - SonataDoctrineORMAdminBundle:Form:form_admin_fields.html.twig filter: - SonataDoctrineORMAdminBundle:Form:filter_admin_fields.html.twig types:

Sonata Admin Bundle: show total count of collection on list view

こ雲淡風輕ζ 提交于 2019-12-04 12:15:33
Is there any way to show total count of collection on list view? Imagine that there is a user that can have many links. How can I show total links count on list view? Show field it is quite easy, there is solution for sorting by this virtual field. Entity/Some.php more about count here Extra Lazy Associations public function getCommentsCount() { return $this->getComments()->count(); } SomeAdmin.php override createQuery and configure list field public function createQuery($context = 'list') { $query = parent::createQuery($context); if ('list' === $context) { $rootAlias = $query->getRootAliases(

Sonata Admin Bundle Type Collection Customisation

余生颓废 提交于 2019-12-04 11:26:33
问题 For example I have 3 entities: Category Subcategory Product In SonataAdminBundle I'd like to be able to add Subcategory while editing Category and Products while editing Subcategory. Following this idea I created fields, but SonataAdminBundle starts playing "Inception" with them. When I open Category I see related Subcategories which contain related Products. How can I cut off "Products" field in this case? Update: My classes (simplified) look like this: // .../CoreBundle/Admin/CategoryAdmin

Sonata Admin Bundle - Form type: sonata_type_collection - custom template?

走远了吗. 提交于 2019-12-04 07:51:36
问题 Is it possible to override the template for the form type: "sonata_type_collection"? Ive tried along these lines: $formMapper->add('slides', 'sonata_type_collection', array(), array( 'edit' => 'inline', 'inline' => 'table', 'sortable' => 'priority', 'template' => 'MyBundle:Form:slides.admin.html.twig' )); but to no avail. I know I could override the entire template, but I only want to do it for this form, not all the places where I use this form type. Does anyone know if this is possible?

sonata admin custom list field (not from entity)

与世无争的帅哥 提交于 2019-12-03 21:23:03
Sonata admin bundle documentation seems scarce and I did not find a way implement this. Goal: display boolean value in field list. Value should calculated for each object from other properties. I managed to implement this for datagridFilter as doctrine_orm_callback but not for listFields. Working code for configureDatagridFilters() : // LicenceAdmin.php protected function configureDatagridFilters(DatagridMapper $datagridMapper) { $datagridMapper->add('isValid', 'doctrine_orm_callback', [ 'callback' => [$this, 'isValidFilterCallback'], 'field_type' => 'checkbox', ]); } public function