sonata-admin

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

Symfony2 - Give a default filter in a list of elements of Sonata Admin

纵饮孤独 提交于 2019-12-20 10:39:08
问题 I have a list of elements of type Vehicle and I show these elements with Sonata Admin. I allow to filter these elements by the "status" field, but I want that, when the list is showed, only the active vehicles are showed, and if somebody wants to see the inactive vehicles, uses the filter and select the inactive status. I would like to know if somebody Knows the way to apply filters by default for a list of elements using Sonata Admin. Here is my code: public function configureListFields

How to implement many-to-many relationships in Sonata Media Bundle

[亡魂溺海] 提交于 2019-12-20 09:36:14
问题 I am trying to relate SonataMediaBundle to another Entity: Products with a relation ManyToMany. The schema and relation are well created. However, when I edit or create a new product, I try to add a button where I can search a media file through the media library and a button to upload a new file. For a relation OneToMany, this is easily done in Admin\ProductAdmin::configureFormFields by adding: ->add('image', 'sonata_type_model_list', array( 'required' => false ), array( 'link_parameters' =>

Sonata admin bundle, manipulate objects

蹲街弑〆低调 提交于 2019-12-20 07:14:19
问题 I have 2 entities with one to many relationship project and prototype And I've been looking for a way to list the prototypes that belong to a project in the show action . here is my project entity: <?php namespace AppBundle\Entity; use Doctrine\ORM\Mapping as ORM; /** * Projet * * @ORM\Table() * @ORM\Entity(repositoryClass="AppBundle\Entity\ProjetRepository") */ class Projet { /** * @var integer * * @ORM\Column(name="id", type="integer") * @ORM\Id * @ORM\GeneratedValue(strategy="AUTO") */

No Entity Manager in Custom Class and ContextErrorException

偶尔善良 提交于 2019-12-20 01:46:48
问题 I'm trying to create custom Form in Sonata-Admin and I want to get data from database to choices box. When I'm trying to get data via getEntityManager() I got error No entity manager defined for class \Admin\AdminBundle\Entity\Category I tried to add entity manager to first argument in service.yml [code below] services: sonata.admin.category: class: Admin\AdminBundle\Admin\Category tags: - {name: sonata.admin, manager_type: orm, group: "Content", label: "Kategoria"} arguments: - @doctrine.orm

SonataAdminBundle - check changes in `preUpdate` hook

為{幸葍}努か 提交于 2019-12-19 06:22:20
问题 Is it possible to check if field was changed on preUpdate hook? I'm looking for something like preUpdate hasChangedField($fieldName) Doctrine functionality. Any ideas? 回答1: This question is a bit similar to this one Your solution is just to compare the field of the old object with the new one and see where it differs. So for example: public function preUpdate($newObject) { $em = $this->getModelManager()->getEntityManager($this->getClass()); $originalObject = $em->getUnitOfWork()-

SonataAdminBundle - check changes in `preUpdate` hook

坚强是说给别人听的谎言 提交于 2019-12-19 06:22:05
问题 Is it possible to check if field was changed on preUpdate hook? I'm looking for something like preUpdate hasChangedField($fieldName) Doctrine functionality. Any ideas? 回答1: This question is a bit similar to this one Your solution is just to compare the field of the old object with the new one and see where it differs. So for example: public function preUpdate($newObject) { $em = $this->getModelManager()->getEntityManager($this->getClass()); $originalObject = $em->getUnitOfWork()-

SonataAdmin: replace ID in breadcrumbs

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-19 06:14:14
问题 How can I replace Object's ID in SonataAdmin breadcrumbs by some other text? If I set __toString() in my document, it works only for editing. When I attempt to create new record, there is something like MyDocument:0000000000e09f5c000000006a48ef49 in the last breadcumb. I'm searching for a method which allows me to set some text as the last breadcump if Document::toString() returns null. 回答1: This behaviour is implemented directly in the entity: public function __toString() { return $this-

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

Session lost during impersonation

感情迁移 提交于 2019-12-19 03:36:05
问题 I use SonataAdminBundle with configured sonata_user in config.yml : sonata_user: impersonating: route: _profile_logged # more config I have my admin panel under /admin prefix. I've configured UserAdmin (based on User entity) with impersonating field. I've tried to go to impersonate user by clicked link in my admin panel and I saw application (not admin panel) login page. I checked developer toolbar and I noticed that request for impersonate user was redirected to login page. It's quite