sonata-admin

Sonata Admin configureListFields

我只是一个虾纸丫 提交于 2019-12-11 11:15:38
问题 is it possible to make a custom query in sonataadmin in configureListFields ? . in this function : protected function configureListFields(ListMapper $listMapper) { $listMapper ->>add(.... ; } thank you ! 回答1: You should override createQuery method like this (source): public function createQuery($context = 'list') { $query = parent::createQuery($context); // this is the queryproxy, you can call anything you could call on the doctrine orm QueryBuilder $query->andWhere( $query->expr()->eq($query

How to override Sonata Media Bundle templates?

喜你入骨 提交于 2019-12-11 10:08:00
问题 I'm currently using SonataAdminBundle for the creation of a Back Office and I've integrated SonataMediaBundle (app-dev version) 2 days ago. The edit/create template from sonata bundle however has some errors! I've fixed them (and they are just twig errors). But I can't just make the changes in the vendor. What is the correct way to overwrite the SonataMediaBundle templates? I've tried the classic AdminBundle way but it doesn't work! here's the code: sonata.admin.media: class: Acme\AdminBundle

Saving embedded collections

两盒软妹~` 提交于 2019-12-11 08:56:22
问题 I have 2 Entities: Game Batting A Game has several other properties, date , location etc A Game has several Batting Entites, i.e a game of cricket A Batting has several properties, Runs, Dismissal, Player Game.php /** * * @ORM\OneToMany(targetEntity="Batting", mappedBy="game", cascade={"persist", "remove"}) */ private $battings; /** * Add battings * * @param \CW\CricketBundle\Entity\Batting $battings * @return Game */ public function addBatting(\CW\CricketBundle\Entity\Batting $battings) {

Sonata-admin Bundle installation. Class SonataCoreBundle not found

纵饮孤独 提交于 2019-12-11 08:23:39
问题 I'm currently trying to install the sonata-admin bundle on an empty Symfony2.4 project. I downloaded the following bundles: php composer.phar require sonata-project/admin-bundle php composer.phar require sonata-project/doctrine-orm-admin-bundle I register these bundles in my appkernel.php: new Sonata\CoreBundle\SonataCoreBundle(), new Sonata\BlockBundle\SonataBlockBundle(), new Sonata\jQueryBundle\SonatajQueryBundle(), new Knplabs\KnpMenuBundle\Knp\Bundle\MenuBundle\KnpMenuBundle(), new

Symfony - Set Sonata Admin filter operator to “is equal to” as default option

…衆ロ難τιáo~ 提交于 2019-12-11 08:21:26
问题 In sonata admin I have a working filter in my admin class: protected function configureDatagridFilters(DatagridMapper $datagridMapper) { $datagridMapper ->add('client.name'); } The filter will default to match "contains" (LIKE operator) like this: I would like the filter to use "is equals to" (= operator) as the default option instead of "contains": Unfortunately I couldn't find questions or answers related to this in SO, google, and the Sonata docs 9.4 filters is currently not documented.

SonataAdmin child admin route visible in debug but not found

南楼画角 提交于 2019-12-11 07:20:46
问题 php bin/console debug:router |grep postboxmessage pt__RG__admin_mea_postbox_postboxmessage_list ANY ANY ANY /admin/mea/postbox/postboxmessage/list pl__RG__admin_mea_postbox_postboxmessage_list ANY ANY ANY /pl/admin/mea/postbox/postboxmessage/list en__RG__admin_mea_postbox_postboxmessage_list ANY ANY ANY /en/admin/mea/postbox/postboxmessage/list pt__RG__admin_mea_postbox_postboxmessage_create ANY ANY ANY /admin/mea/postbox/postboxmessage/create pl__RG__admin_mea_postbox_postboxmessage_create

Sonata Admin + show all items on list view (not per page)

☆樱花仙子☆ 提交于 2019-12-11 06:34:56
问题 In the Sonata Admin Bundle you have a list view where you can add fields you want to show in your table. At the bottom of the table you have the number of results and pagination. I like the pagination and items per page. But I would like to show ALL the items at the load of the page. So all the items are shown on the page but you can still choose to decrease the number of results per page. The problem is I don't have a clue on how to do this. Can someone set me on my way? 回答1: In SonataAdmin

How to override xml under config directory to hide SonataMediaBundle and Classification setting from dashboard

谁都会走 提交于 2019-12-11 06:29:00
问题 I have installed SonataMediaBundle and SonataClassification Bundle with SonataAdminBundle Media Library and Classification Library tables appear automatically in admin dashboard. However, I would like to remove this two panes. Now, I have found these settings are written in vendor/sonata-project/classification-bundle/Resources/config/admin.xml I guess this file is related though, this is in vendor directory. I have my original bundle ApplicationSonataClassificationBundle to override

How to retrieve subject in Sonata configureListFields?

若如初见. 提交于 2019-12-11 06:16:18
问题 I use Sonata Admin Bundle in my Symfony project and created an ArticleAdmin class for my Article entity. In the list page, I added some custom actions to quickly publish, unpublish, delete & preview each article. What I want to do is to hide publish button when an article is already published & vice versa. To do this, I need to have access to each object in method configureListFields(). I would do something like this: protected function configureListFields(ListMapper $listMapper) {

Sonata 2 display 2 fields in the same column

谁说我不能喝 提交于 2019-12-11 05:38:52
问题 I display the list form of Sonata. I have 2 fields : firstname, lastname. I want to display 2 fields in the same column. Currently, I'm doing $listMapper->add('firstname', 'text', array('label' => 'First Name')) ->add('lastname', 'text', array('label' => 'Last Name')); How can I combine 2 fields in one without to change the Entity 回答1: This is how i do it: Say firstname and lastname are properties of User. In your entity class User, just add: /** * @return string */ public function