sonata-admin

SonataUserBundle override form profile

戏子无情 提交于 2019-12-05 05:42:28
问题 I am using SonataUserBundle and I am trying to override the edit profile form, but I am not sure about the services.yml and the config.yml. Here is the code. ProfileType.php namespace Application\Sonata\UserBundle\Form\Type; use Symfony\Component\Form\FormBuilderInterface; use Sonata\UserBundle\Form\Type\ProfileType as BaseType; class ProfileType extends BaseType { public function buildForm(FormBuilderInterface $builder, array $options) { parent::buildForm($builder, $options); $builder->add(

using sonata_type_collection against a custom form type instead of a property/relationship with another entity

杀马特。学长 韩版系。学妹 提交于 2019-12-05 05:31:27
问题 is it possible to use sonata_type_collection against a custom form type instead of a property/relationship with another entity? Something like this: $formMapper->add('foo', 'sonata_type_collection', array('type' => new \myVendor\myBundleBundle\Form\Type\BlockType() )); Which throws me the following error The current field `contingut` is not linked to an admin. Please create one for the target entity : `` EDIT: Something like this did the trick: $formMapper->add('contingut', 'collection',

sonata admin custom list field (not from entity)

戏子无情 提交于 2019-12-05 04:59:01
问题 Sonata admin bundle documentation seems scarce and I did not find a way implement this. Goal: display boolean value in field list. Value should calculated for each object from other properties. I managed to implement this for datagridFilter as doctrine_orm_callback but not for listFields. Working code for configureDatagridFilters() : // LicenceAdmin.php protected function configureDatagridFilters(DatagridMapper $datagridMapper) { $datagridMapper->add('isValid', 'doctrine_orm_callback', [

Adding a custom form inside the show template of a Sonata Admin Entity

我与影子孤独终老i 提交于 2019-12-05 02:50:10
I want to generate a small form inside a Sonata Admin show template. What I have done so far is creating the function in the custom CRUD for that specific entity (order) that extends from Sonata's default CRUD; public function approveOrderAction($id = null) { $request = $this->getRequest(); $id = $request->get($this->admin->getIdParameter()); $order = $this->admin->getObject($id); $approveForm = $this->createFormBuilder($order) ->add('reqSecondApprover', 'checkbox', array('label' => 'Require second Approval', 'required' => false)) ->add('secondApprover', 'choice', array('choices' => Crud:

Overriding the User Admin Form

做~自己de王妃 提交于 2019-12-05 00:47:47
问题 I'm trying to override the SonataUser/Admin/Model/UserAdmin 's configureFormFields() because I need to remove some default fields from the admin form. So I have copied the file vendor/bundles/Sonata/UserBundle/Admin/Model/UserAdmin.php in my bundle app/Application/Sonata/UserBundle/Admin/Model/UserAdmin.php and modified it. Then declared it as a service: # app/application/Sonata/UserBundle/Resources/config/services.yml services: application_user.registration.form.type: class: Application

Sonata Admin Dashboard: configure actions per entity

非 Y 不嫁゛ 提交于 2019-12-05 00:34:28
问题 I'm using the SonataAdminBundle as base for an administration interface for a Symfony2 (v2.0.x) powered website. Entities which are added to the dashboard in SonataAdmin have the following actions by default: add list This works fine for most entities, however the website has a few entities for which data is not added via the admin interface - i.e. they are entered from the public facing website. Administrators only need to view them ("list" action in dashboard), edit them or delete them.

How to get child object in embedded Admin class in Sonata Admin?

て烟熏妆下的殇ゞ 提交于 2019-12-05 00:14:25
问题 I'm trying to get and manipulate the actual object related to a ImageAdmin class in SonataAdmin (using Symfony 2.3). This works fine when the ImageAdmin class is the only one being used. But when ImageAdmin is embedded in another Admin it goes horribly wrong. Here's what works when you don't have embedded Admins: class ImageAdmin extends Admin { protected $baseRoutePattern = 'image'; protected function configureFormFields(FormMapper $formMapper) { $subject = $this->getSubject(); } } But when

One to Many relations and add/edit form in SonataAdmin and Symfony2

三世轮回 提交于 2019-12-04 22:02:36
I have a simple Symfony2 application with two entities: Municipality and Poi. There is a relation "One-To-Many" between Municipality and Pois (i.e: zero or more pois placed in one municipality), so the Entity files are like this: Poc\PocBundle\Entity\Municipality.php <?php // Poc\PocBundle\Entity\Municipality.php namespace Poc\PocBundle\Entity; use Doctrine\ORM\Mapping as ORM; /** * Municipality * * @ORM\Table() * @ORM\Entity(repositoryClass="Poc\PocBundle\Entity\MunicipalityRepository") */ class Municipality { /** * @ORM\OneToMany(targetEntity="Poi", mappedBy="municipality") */ protected

Problems showing fields with Sonata Admin - Symfony 2.0

心不动则不痛 提交于 2019-12-04 21:20:28
I want to show some fields of an object with SonataAdmin. One of these fields is an integer (status) in the database, but I don't want to show the integer, else a specific string depending on the value of this field. public function configureListFields(ListMapper $listMapper) { $listMapper ->addIdentifier('name') ->add('notice') ->add('start') ->add('end') ->add('status') ; } Is it possible? And a second question: in the same example, I want to add a field which is not mapped in the database (people) because this is calculated with data related with other objects. public function

Method “currentAncestor” for object “Knp\\Menu\\MenuItem” does not exist in Sonata

匆匆过客 提交于 2019-12-04 17:29:57
I'm new to Symfony2 and I just installed it along with fosUserBUndle 1.3.3, Sonata Admin BUndle, and Sonata User BUndle. Now I get an error that I cannot resolve. Here is my error: (url localhost:8000/profile/ ) : Method "currentAncestor" for object "Knp\Menu\MenuItem" does not exist in SonataBlockBundle:Block:block_side_menu_template.html.twig at line 29 I am able to login succesfully, but I get this error after login. Any help would be greatly appreciated. Thanks open file block_side_menu_template.html.twig at /var/www/html/MySymProject/vendor/sonata-project/block-bundle/Resources/views