sonata-admin

toString method for SonataAdminBundle Listing in Symfony2

谁都会走 提交于 2019-12-01 19:12:44
问题 In Symfony 2.3 i am using SonataAdminBundle ( master ) and i am trying to get ManyToMany working in Listing. The Problem is that SonataAdminBundle is asking for a toString() method. Implementing this method to the related Entity solves the problem. My Question: Do i have to implement the toString method or is there a Option to tell SonataAdminBundle a property for using instead of calling the toString method? Thank you 回答1: As far as I know, it's mandatory. But you can return another property

Format for time display?

不打扰是莪最后的温柔 提交于 2019-12-01 15:17: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? likeitlikeit Try using ->add('fromDate','datetime',array('date_format' => 'yyyy-MM-dd HH:mm:ss')) By the way, the relevant code is here . I think your format option gets overwritten by the system

Sonata User Bundle + Symfony 3.x

半世苍凉 提交于 2019-12-01 04:53:11
I use Symfony 3.0.6, Sontata Admin Bundle 3.0.0 and the Doctrine ORM Admin Bundle on dev-master. The user bundle doesnt work even with dev-master. Is there a solution for Symfony 3.x yet? Your requirements could not be resolved to an installable set of packages. Problem 1 - Conclusion: remove symfony/symfony v3.0.6 - Conclusion: don't install symfony/symfony v3.0.6 - Conclusion: don't install symfony/symfony v3.0.5 - Conclusion: don't install symfony/symfony v3.0.4 - Conclusion: don't install symfony/symfony v3.0.3 - Installation request for sonata-project/user-bundle dev-master -> satisfiable

SonataAdminBundle - check changes in `preUpdate` hook

拈花ヽ惹草 提交于 2019-12-01 04:21:25
Is it possible to check if field was changed on preUpdate hook? I'm looking for something like preUpdate hasChangedField($fieldName) Doctrine functionality. Any ideas? Geert Wille This question is a bit similar to this one Your solution is just to compare the field of the old object with the new one and see where it differs. So for example: public function preUpdate($newObject) { $em = $this->getModelManager()->getEntityManager($this->getClass()); $originalObject = $em->getUnitOfWork()->getOriginalEntityData($newObject); if ($newObject->getSomeField() !== $originalObject['fieldName']) { //

SonataAdmin: replace ID in breadcrumbs

半世苍凉 提交于 2019-12-01 04:11:41
How can I replace Object's ID in SonataAdmin breadcrumbs by some other text? If I set __toString() in my document, it works only for editing. When I attempt to create new record, there is something like MyDocument:0000000000e09f5c000000006a48ef49 in the last breadcumb. I'm searching for a method which allows me to set some text as the last breadcump if Document::toString() returns null. TautrimasPajarskas This behaviour is implemented directly in the entity: public function __toString() { return $this->getFoo() ? : '-'; } Bundles are using variants of this, including return (string)$this-

Sonata User Bundle + Symfony 3.x

最后都变了- 提交于 2019-12-01 01:56:18
问题 I use Symfony 3.0.6, Sontata Admin Bundle 3.0.0 and the Doctrine ORM Admin Bundle on dev-master. The user bundle doesnt work even with dev-master. Is there a solution for Symfony 3.x yet? Your requirements could not be resolved to an installable set of packages. Problem 1 - Conclusion: remove symfony/symfony v3.0.6 - Conclusion: don't install symfony/symfony v3.0.6 - Conclusion: don't install symfony/symfony v3.0.5 - Conclusion: don't install symfony/symfony v3.0.4 - Conclusion: don't install

Sonata User - Security on custom field

℡╲_俬逩灬. 提交于 2019-11-30 15:27:55
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 ? Yes ACL is the way to go. create a CompanyVoter implementing VoterInterface and check if the user is on the same company inside it's vote()

Programmatically set the value of a Select2 ajax

百般思念 提交于 2019-11-30 12:31:55
问题 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

disable action in sonata admin bundle CRUD

烈酒焚心 提交于 2019-11-30 11:28:11
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. rpg600 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\RouteCollection; Docs : http://sonata-project.org/bundles/admin/master/doc/reference/routing.html#removing-a

Sort list view in Sonata Admin by related entity fields

别来无恙 提交于 2019-11-30 07:27:46
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(ListMapper $listMapper) { $listMapper ->addIdentifier('id') ->add('name') ->add('state') ->add('state