sonata-admin

Sonata Admin ManyToOne error: “sonata_type_collection - mapping : 2 ”

不羁的心 提交于 2019-12-06 04:41:13
I want to use Sonata Admin Gallery feature into my News Entity . Here is my code News.yml .... manyToOne: gallery: targetEntity: Application\Sonata\MediaBundle\Entity\Gallery inversedBy: news_gallery cascade: ["persist"] nullable: true Gallery.orm.xml .... <one-to-many field="news_gallery" target-entity="Wenweipo\NewsBundle\Entity\News" mapped-by="gallery" /> NewsAdmin.php protected function configureFormFields(FormMapper $formMapper) { $formMapper ->add('gallery', 'sonata_type_collection', array( 'cascade_validation' => true, ), array( 'edit' => 'inline', 'inline' => 'table', 'sortable' =>

How to display top and side menu in SonataAdminBundle?

耗尽温柔 提交于 2019-12-06 04:16:09
问题 There are no documents talk about that. Please help me. Thank you 回答1: Admin top menu is created automatically based on group item in admin service definition. All admin services can be grouped and are displayed in top menu. Example (see group="sonata_page" where sonata_page is name of menu group): Admin side menu can be created with configureSideMenu() method in your admin service. Example 来源: https://stackoverflow.com/questions/14837194/how-to-display-top-and-side-menu-in-sonataadminbundle

Symfony2 - Entire child entity in form and Twig template

空扰寡人 提交于 2019-12-06 03:31:50
In a Sonata admin form, I'd like to display all images related to the current object. Don't need to edit them. I managed to get this working with an entity field type and its property option to select the image URL as label so I can call all pictures in the template : ->add('image', 'entity', array( 'class' => 'Hop\HopBundle\Entity\Image', 'property' => 'image_url', 'query_builder' => function($er) use ($object) { return $er->createQueryBuilder('i') ->where('i.object = :object') ->setParameter('object', $object) ; }, 'expanded' => true, )) . {% for child in form %} <img src="{{ child.vars

How to extends Sonata\\DoctrineORMAdminBundle\\Model\\ModelManager

喜你入骨 提交于 2019-12-06 01:58:48
I want some changes in ModelMangaer then I was extending ModelManager but It's not working. I don't know why ? Any one tell me why it is not working? File where I extend Sonata\DoctrineORMAdminBundle\Model\ModelManager-> <?php use Sonata\DoctrineORMAdminBundle\Model\ModelManager; class ModelManager extends ModelManager { /** * {@inheritdoc} */ public function getSortParameters(FieldDescriptionInterface $fieldDescription, DatagridInterface $datagrid) { $values = $datagrid->getValues(); $values = $_GET['filter']; if ($fieldDescription->getName() == $values['_sort_by']) { if ($values['_sort_order

Symfony2: Overriding createAction() in SonataAdmin

不羁岁月 提交于 2019-12-06 01:47:21
问题 I've been googling as crazy the last days trying to figure out (with no success) how override a SonataAdmin action to capture the session username and save it in the foreign key field. AttachmentAdminController class: <?php namespace Application\Sonata\UserBundle\Controller; use Sonata\AdminBundle\Controller\CRUDController as Controller; #use Symfony\Bundle\FrameworkBundle\Controller\Controller; use FOS\UserBundle\Entity\User; use Symfony\Component\Security\Core\SecurityContextInterface; use

set role for users in edit form of sonata admin

淺唱寂寞╮ 提交于 2019-12-05 18:50:31
I'm using Symfony 2.1 for a project. I use the FOSUserBundle for managing users & SonataAdminBundle for administration usage. I have some questions about that: As an admin, I want to set roles from users in users edit form. How can I have access to roles in role_hierarchy ? And how can I use them as choice fields so the admin can set roles to users? When I show roles in a list, it is shown as string like this: [0 => ROLE_SUPER_ADMIN] [1 => ROLE_USER] How can I change it to this? ROLE_SUPER_ADMIN, ROLE_USER I mean, having just the value of the array. Romain Bruckert Based on the answer of

Sonata Admin Action Button to Pre Filtered List

北城以北 提交于 2019-12-05 16:38:06
I am rather new to Symfony (2 weeks) so forgive my ignorance. I am trying to add a custom action button that will link to a pre filtered list of a RELATED entity. I have done a lot of research but can't quite seem to find what I need. Currently I have two entities Books and Authors with a manyToOne relation ship. I have these set up in Sonata Admin in the usual way and all works well. I even have an author filter on the book list page which I am hoping can be leveraged to accomplish my goal. In the Author list view, I would like to add an action button on each row next to View and Edit, called

Assert unique validation in Sonata Admin

筅森魡賤 提交于 2019-12-05 12:32:39
I'm using Symfony 2.1 for a project. I use SonataAdminBundle for administration usage. i want to add an assert to my slug property in my admin class.. how can i do this? in my entity i had set the assertion but it seems that it doesn't work here :( related codes: the entity : /* * @ORM\Table(name="default_doctor_specialty") * @UniqueEntity("uniqueSlugName") * @ORM\Entity */ class Test { //.. /** * @var string * @Gedmo\Slug(fields={"name"},unique=false) * * @ORM\Column(name="unique_slug_name", type="string", length=255, nullable=false , unique=true) */ private $uniqueSlugName; } in admin class:

Exporting one to many relationship on sonata admin

怎甘沉沦 提交于 2019-12-05 10:42:16
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 function getExportFields() { return array('name','tel','email','deviceType','postedOn','createdAt',

symfony2.1 bundle version confusion, for symfony and sonata admin / knp menu bundle

走远了吗. 提交于 2019-12-05 06:05:49
I want to use symfony2.1 for a new project. I try to install symfony2 with composer. But there were multiple errors/problems and so I have also questions for each problem in bold font style . Sometimes I don't know if I do it the right way. I want to use a stable version so I chosen the 2.1.0 version and not the dev/master. php composer.phar create-project symfony/framework-standard-edition symfony v2.1.0 the result was this: Installing symfony/framework-standard-edition (v2.1.0) - Installing symfony/framework-standard-edition (v2.1.0) Downloading: 100% Created project in symfony Loading