sonata-admin

List Images in sonata admin bundle

梦想的初衷 提交于 2019-12-04 16:50:56
I am new to Symfony & trying to list images in sonata admin bundle. But i am bit confuse how to get an object in twig file so that i can get my exact path for image source. here is my code protected function configureListFields(ListMapper $listMapper) { // $image = $this->getSubject(); $listMapper ->addIdentifier('caption') ->add('image','string', array('template' => 'swaamImageUploaderBundle:Admin:list_image.html.twig')) ; } and here is my list_image.html.twig file {% extends 'SonataAdminBundle:CRUD:base_list_field.html.twig' %} {% block field%} <img src="{{ 'uploads/images

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 preview image from some entity in list mapper without sonata media bundle

谁说我不能喝 提交于 2019-12-04 11:34:00
I was wondering how should i approach this problem. In sonata admin dashboard i have users and i would like to preview users profile pictures in thumbnails of a ListMapper. I'm new to symfony and still a bit confused trying to wrap my head around these concepts. You need to create a custom template where you display the image of your user, i will assume that your Entity User as a Picture Entity which has a path method that gives the image URL : picture.html.twig {% extends 'SonataAdminBundle:CRUD:base_list_field.html.twig' %} {% block field %} <div> {% if object.picture != null %} <img src="{{

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?

How to display top and side menu in SonataAdminBundle?

笑着哭i 提交于 2019-12-04 07:48:10
There are no documents talk about that. Please help me. Thank you 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: Overriding createAction() in SonataAdmin

萝らか妹 提交于 2019-12-04 06:54:59
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 Symfony\Bridge\Monolog\Logger; use Mercury\CargoRecognitionBundle\Entity\Attachment; class

datagrid filter for relation object as text field (insted of dropdown) in sonata admin in symfony 2.4

主宰稳场 提交于 2019-12-04 06:41:22
I have entity 'Action' with relation to 'User'. Created Admin CRUD controller in SonataAdminBundle. Everything works fine except user filter is rendered as dropdown list. I have 8k user count and growing so you must see why this is a problem. I want user filter to be text input and on submit to search with LIKE %username% Right now I add user filter like this - $datagridMapper->add('user') . I know I can add filter type and field type but I am not able to find the right combination and options. Found information on http://sonata-project.org/bundles/doctrine-orm-admin/master/doc/reference

Sonata Admin search feature

人走茶凉 提交于 2019-12-04 05:55:40
I recently updated my symfony2 project vendors. Thus I got latest Sonata Admin Bundle version (updated from 2.2.5 to 2.2.6). I saw there is a new search feature in this release but I can't get it work. I can't figure out what I'm doing wrong. Drives me crazy. Here is my composer.json require : "require": { "php": ">=5.3.3", "symfony/symfony": "2.3.*", "doctrine/orm": ">=2.2.3,<2.4-dev", "doctrine/doctrine-bundle": "1.2.*", "twig/extensions": "1.0.*", "symfony/assetic-bundle": "2.3.*", "symfony/swiftmailer-bundle": "2.3.*", "symfony/monolog-bundle": "2.3.*", "sensio/distribution-bundle": "2.3.*

Adding customised validation rules to SonataUserBundle

♀尐吖头ヾ 提交于 2019-12-04 02:32:29
I have installed SonataUserBundle according to the docs and it all works fine. Except that I cannot add custom validation rules. My understanding is that the new rules should be added to a new Validation Group and then config.yml is updated to tell SonataUserBundle (or FosUserBundle) to add the new rules to the validation sequence. I have tried this, in various ways, but the new rules just don't seem to be picked up at all... Here's the configuration I'm using... (For the sake of this example, I'm just trying to adding a NotNull constraint to a new foo field. In reality I would like to see