sonata-admin

Customize form field rendering

喜夏-厌秋 提交于 2019-11-29 09:50:35
问题 I would like to customize the rendering of a form field in the edit page from sonata admin bundle to include an applet that uses the text content of a field. I know that I have to edit the configureFormFields function in the admin class, but I need to know 3 things: What is the syntax to provide a field form template Where to put the template file ( which directory ) What the template have to looks like. 回答1: Found a solution What i have done is: Created a field type, lets call it myfieldType

Correct way to use FormEvents to customise fields in SonataAdmin

非 Y 不嫁゛ 提交于 2019-11-29 07:50:26
I have a Sonata Admin class with some form fields in it, but I'd like to use the FormEvents::PRE_SET_DATA event to dynamically add another form field based on the bound data. However, I'm running into several problems: 1) The only way I can find to add the form field to the correct 'formGroup' in the admin is by adding the new field twice (once via the formMapper and once via the form itself)... this seems very wrong and I cannot control where in the formGroup it appears. 2) The added element doesn't seem to know that it has a connected Admin (probably because it is added using Form::add() ).

Sonata admin bundle order

一个人想着一个人 提交于 2019-11-29 05:54:52
How to change default entity order in SonataAdminBundle for list action? answer :) add this to your admin class protected $datagridValues = array( '_page' => 1, '_sort_order' => 'DESC', // sort direction '_sort_by' => 'id' // field name ); pilot You can add another sort order or set a default one via the constructor like this: public function __construct($code, $class, $baseControllerName) { parent::__construct($code, $class, $baseControllerName); if (!$this->hasRequest()) { $this->datagridValues = array( '_page' => 1, '_sort_order' => 'ASC', // sort direction '_sort_by' => 'artist_id' //

Add custom button to edit page of sonata admin bundle

独自空忆成欢 提交于 2019-11-29 02:17:40
As you know, sonata admin bundle comes with three buttons in edit page which are "Add new, update and delete". I can remove delete button with this: protected function configureRoutes(RouteCollection $collection) { $collection ->remove('delete') ; } But I want to also add "Send message to User" button in edit of UserAdmin. How can I do this? I can't find any documentation about that in sonata docs. You should hint the parameter if the file is in other namespace, and the add() method should work, but then you have to overwrite the Sonata's CRUD template to be able to display an other button

Symfony2 1:M / 1:1 Relationship and Sonata Admin Form

懵懂的女人 提交于 2019-11-29 00:40:11
I've hitting my head against the wall for countless hours now and I hope SO can be of help! I have Retailer, Branch and RetailerBranches entities which work just fine, retailers can have many branches and a branch can only have one retailer. The hard part happens when trying to make Sonata Admin (SonataAdminBundle) play nice with that relationship. In their simplest form, they look like this: Retailer entity /** * @ORM\Column(name="ID", type="integer", nullable=false) * @ORM\Id * @ORM\GeneratedValue(strategy="IDENTITY") */ private $id; /** * Relation * * @ORM\OneToMany(targetEntity=

Labels in Sonata Admin Bundle

瘦欲@ 提交于 2019-11-29 00:39:59
问题 I have started new with the sonata admin bundle. its very handy and easy to setup and use , but i can't seem to get the translation fixed for the default labels e.g link_add, link_list are coming instead of proper english labels. #SonataAdmin sonata_block: default_contexts: [cms] blocks: sonata.admin.block.admin_list: contexts: [admin] sonata.block.service.text: sonata.block.service.rss: sonata_admin: title: Sonata Project title_logo: /bundles/sonataadmin/logo_title.png templates: # default

Sonata Admin - Only allow show what logged in user has created

三世轮回 提交于 2019-11-28 21:42:01
问题 I've setup a sonata admin interface which allows users to create specific content, but how do I restrict users from editing content created by other users? For arguments sake, a user logs in and creates a blog. In the list view of blogs, only the blogs that user created should be displayed. Currently, everything is displayed to every user - I do have groups/roles setup to restrict access to admin areas, which works fine. The only way I can currently think of only show a specific logged in

Sonata Admin Bundle One-to-Many relationship not saving foreign ID

梦想与她 提交于 2019-11-28 20:52:17
I have a problem with the SonataAdminBunle in combination with symfony 2.2. I have a Project entity and a ProjectImage entity and specified a One-to-Many relationship between these two like so: class Project { /** * @ORM\OneToMany(targetEntity="ProjectImage", mappedBy="project", cascade={"all"}, orphanRemoval=true) */ private $images; } class ProjectImage { /** * @ORM\ManyToOne(targetEntity="Project", inversedBy="images") * @ORM\JoinColumn(name="project_id", referencedColumnName="id") */ private $project; } I've configured the ProjectAdmin and ProjectImageAdmin: class ProjectAdmin extends

Sonata Admin Bundle: DatePicker range

三世轮回 提交于 2019-11-28 06:51:48
How would I create a doctrine_orm_datetime_range filter in the Sonata Admin Bundle which uses the jQuery UI datepicker? I tried the following, but it doesn't work: protected function configureDatagridFilters(DatagridMapper $datagridMapper) { $datagridMapper ->add('datumUitgevoerd', 'doctrine_orm_datetime', array('widget' => 'single_text'), null, array('required' => false, 'attr' => array('class' => 'datepicker'))) ; } pulzarraider UPDATED 2016-02-02 If you are using 3.* Symfony the following twig configuration must be used: # app/config/config.yml twig: # ... form_themes: - 'SonataCoreBundle

SonataAdminBundle custom rendering of text fields in list

独自空忆成欢 提交于 2019-11-28 06:43:52
I'm using symfony2 and SonataAdminBundle. I have a simple Entity called Post in which I have content field that is basically html text (from a ckeditor for the record). I need to display in the Post list the content field as raw html, without escaping it. Hacking base_list_field template like this {% block field %}{{ value|raw }}{% endblock %} works, but it's clearly not the proper way. Any hints? edit: SOLVED! I've defined a custom html type in the config.yml for sonata_doctrine_orm_admin: sonata_doctrine_orm_admin: templates: types: list: html: MyBundle:Default:list_html.html.twig And