sonata-admin

Format for time display?

Deadly 提交于 2020-01-11 08:15:34
问题 I am making application with symfony2 and sonata-admin bundle. public function configureListFields(ListMapper $listMapper) { $listMapper ->addIdentifier('id') ->add('fromDate'); it shows time like this September 1, 2013 02:00 so I changed - ->add('fromDate'); + ->add('fromDate',null,array('format' => 'yyyy-MM-dd HH:mm:ss')) but it still show the same. please give me how to use format for time display? 回答1: Try using ->add('fromDate','datetime',array('date_format' => 'yyyy-MM-dd HH:mm:ss')) By

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

落爺英雄遲暮 提交于 2020-01-11 03:49:25
问题 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? 回答1: 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

How to create a custom action not related to entity from sonata admin

我们两清 提交于 2020-01-07 02:57:42
问题 I need to add an action to clear symfony2 cache in sonata admin which will be used for example when JMS translations are updated. I would like to know how to create a custom action not related to entity in sonata admin and how to execute clear cache command from it when the admin will click on the corresponding custom link. 回答1: You may create an action in very straight-forward Symfony way - create a route, make a common controller for this route. Or call the action in any other way Symfony

SonataAdminBundle json_array field giving INVALID MODE / String conversion error

你。 提交于 2020-01-06 04:33:27
问题 I am using doctrine/dbal v2.9.2 and sonata-project/admin-bundle 3.47.0 I have a simple database table with a data field of jsonb type. /** * @ORM\Column(type="json",nullable=true,options={"jsonb"=true}) */ private $data; When I try to edit this field with SonataAdminBundle I get errors. If I import use Sonata\Form\Type\CollectionType; then I get error: INVALID MODE : sb14b159283_data - type : sonata_type_collection - mapping : json If I import use Sonata\AdminBundle\Form\Type\CollectionType;

How to customize configureDatagridFilters in Sonata Admin to use non related mongodb documents

本小妞迷上赌 提交于 2020-01-06 02:41:05
问题 In my Mongodb I got a passenger document, this is a typical item: { "_id" : ObjectId("51efdf818d6b408449000002"), "createdAt" : 1374674817, "phone" : "222222", .. } I also have a device document that references a passenger document, here is an example: { "_id" : ObjectId("51efdf818d6b408449000001"), "os" : "android.gcm", "passenger" : ObjectId("51efdf818d6b408449000002"), .. } so in other words.. there is no way I can find out the device belonging to a passenger by running a query on

Symfony2, Sonata : Collapsed group

*爱你&永不变心* 提交于 2020-01-05 02:30:48
问题 I've been trying to do something relatively simple but that does not work. I want to be able to collapse groups in sonata to enhance the user's experience. ->with('MyGroup', array('collapsed' => true)) -add('MyField') ->end(); This is based on the Sonata documentation. Pretty simple but i can't see why it does not work. Does array('collapsed' => true) is not enough? Is it an issue? 回答1: The collapsed option seems to have been removed in the latest version of Sonata : in 2.1 it is available

Using Sonata Admin to work with Doctrine json_array fields

我怕爱的太早我们不能终老 提交于 2019-12-31 04:15:18
问题 Is there any 'built in' way to administer Doctrine json_array fields using Sonata Admin? I can't find any useful documentation (or relevant code) in the Symfony / Sonata docs (or code), but I'm hoping that I missed something! Ideally I would like to see the serialised key/value pairs with a way to delete any of them and add some new ones, but I guess I'm going to have to write that up myself... 回答1: You work with json_array just like with any array so You can go with collection type or sonata

SonataAdminBundle Exporter issue with mapped entities

北慕城南 提交于 2019-12-30 10:35:29
问题 There is a standard feature in sonata-admin-bundle to export data using exporter; But how to make export current entity AND mapped ManyToOne entity with it? Basically what I want, is to download exactly same data as defined in ListFields. UPD: In docs, there is only todo UPD2: I've found one solution, but I do not think it is the best one: /** * Add some fields from mapped entities; the simplest way; * @return array */ public function getExportFields() { $fieldsArray = $this->getModelManager(

Symfony2 Sonata admin dynamically change input data based on selected value

烈酒焚心 提交于 2019-12-30 05:28:11
问题 For one of my objects I need to create some dynamic form rendering... But I cant figure out how to do this in Sonata Admin. For example when I create an object I have a field type. In this field I select a type that my object is going to be. Now when I select the type I want to make a field appear, based on the type. For example, if I select type "Carousel" I want to show a field that is selecting all object form entity Gallery. If I select type "Product" I want to display field with all

Sonata Media Bundle : acces media url

允我心安 提交于 2019-12-30 04:04:51
问题 I am using sonata media bundle. and I was wondering how can I access the media url in twig. I just want the url, I do not need to show the media. Any suggestions? 回答1: You have to use the path media helper: {% path media, 'small' %} In the above code, media is an instance of the media entity, and small is the chosen format. http://sonata-project.org/bundles/media/master/doc/reference/helpers.html#twig-usage 回答2: But if you do not want to render the media right there and just store the url in