sonata-admin

Customize form field rendering

爱⌒轻易说出口 提交于 2019-11-30 07:27:00
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. user1254498 Found a solution What i have done is: Created a field type, lets call it myfieldType in myCompany\myBundle\Form\Type\myfieldType.php namespace myCompany\myBundle\Form\Type; use

Programmatically set the value of a Select2 ajax

天大地大妈咪最大 提交于 2019-11-30 04:26:34
I have a Select2 auto-complete input (built via SonataAdmin), but cannot for the life of me figure out how to programmatically set it to a known key/value pair. There's a JS Fiddle here that shows roughly what I have. What I want to know is what function I can attach to the button so that the Select2 field shows the text "NEW VALUE" to the user, and the Select2 field will submit a value of "1" when the form is sent to the server I have tried all sorts of combinations of jQuery and Select2 data and val methods, called against various inputs on the page, but nothing seems to work... surely there

Labels in Sonata Admin Bundle

六月ゝ 毕业季﹏ 提交于 2019-11-30 03:38:46
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 global templates layout: SonataAdminBundle::standard_layout.html.twig ajax: SonataAdminBundle::ajax

Get old data in preUpdate Sonata Admin Bundle

故事扮演 提交于 2019-11-30 03:18:58
问题 I have a product entity and it has an images field that store the images names from the product but the images names depends of a part_number field that is unique, so if the user make a mistake in the part number and he wants to edit it then I also have to change the images names I tried this but it does not works: // class ProductsAdmin extends Admin public function preUpdate($product) { $old_product = $this->getSubject(); if ($old_product->getPartNumber() != $product->getPartNumber) { //

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

谁说胖子不能爱 提交于 2019-11-30 00:58:58
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 users content, is to override the templates? But, surely, this is an obvious and simple configuration

Sonata User - Security on custom field

前提是你 提交于 2019-11-29 21:17:48
问题 I used SonataUser with FOSUser to manage my users and created a custom field company to attach each one to a given company. Now I'd simply need to give users the ability to manage only users attached to the same company: user1 company1 user2 company1 user3 company2 user4 company2 Example: user1 should be able to list/edit only user1 & user2 Should I use ACLs ? Can you point me to the right direction or tutorial to customize SonataUser for this purpose ? 回答1: Yes ACL is the way to go. create a

disable action in sonata admin bundle CRUD

我们两清 提交于 2019-11-29 17:36:07
问题 IS there a simple way to disable some CRUD actions for given admin class? E.g. I just want a list of users added via front-end without the option to manually add them. 回答1: In your admin class : protected function configureRoutes(RouteCollection $collection) { // to remove a single route $collection->remove('delete'); // OR remove all route except named ones $collection->clearExcept(array('list', 'show')); } Also use routeCollection at top of admin class use Sonata\AdminBundle\Route

How to remove fields from the admin user create page of Sonata User Bundle?

天大地大妈咪最大 提交于 2019-11-29 17:23:20
I have installed Sonata Admin Bundle and User Bundle in my Symfony 2.6 application. I found that the User bundle creates a bundle at src/Application/Sonata/UserBundle . When I go to the admin user creation page ( admin/sonata/user/user/create ), I found a lot of fields there: General Username E-Mail-Address Plain password Groups Profile Date of birth Firstname Lastname Website Biography Gender Locale Timezone Phone Social Facebook Uid Facebook Name Twitter Uid Twitter Name Google+ Uid Google+ Name Management Roles Locked Expired Enabled Credentails expired Security Token Two Step Verification

Getting instance of container in custom sonata block

三世轮回 提交于 2019-11-29 12:23:25
I am creating a custom block for dashboard and where I want to display information persisted into the DB. How do I get an instance of the container or doctrine entity manager in the block service? Tried googling alot but nothing substantial has come out so far When you create a new block in sonata, you have to declare it like a service, so you can inject doctrine.orm.entity_manager . I can show you an example of a block where I injected the entity manager: //My\Bundle\Block\MyBlockService use Symfony\Component\HttpFoundation\Response; use Sonata\AdminBundle\Form\FormMapper; use Sonata

Sort list view in Sonata Admin by related entity fields

只愿长相守 提交于 2019-11-29 10:28:06
问题 Using Sonata Admin Bundle, which is a great add-on for Symfony, I have bumped into the problem described as follows. Let's say we have 3 entities: City, State and Country. They all have the properties id and name . City has a many-to-one relation to State and State has a many-to-one relation to Country. They all have __toString methods displaying the value of the property name. We can create a list view for the entity City in Sonata Admin like this: protected function configureListFields