sonata-admin

sonata admin custom list field (not from entity)

与世无争的帅哥 提交于 2019-12-03 21:23:03
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', [ 'callback' => [$this, 'isValidFilterCallback'], 'field_type' => 'checkbox', ]); } public function

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

夙愿已清 提交于 2019-12-03 20:52:23
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', array( 'type' => new \myVendor\myBundleBundle\Form\Type\Block1Type(), 'allow_add' => true, 'allow_delete' =

Use Sonata Field Type on normal Form Class

血红的双手。 提交于 2019-12-03 17:22:43
I'm trying to insert custom sonata form field type on the front page, not in SonataAdmin, something like this: $form = $this->createFormBuilder($content) ->add('titleEs', 'text', array('required' => true, 'label' => 'label.title.spanish', 'attr' => array('class' => 'col-xs-12 form-control input-lg'))) ->add('contentEs', 'ckeditor', array('required' => true,'label' => 'label.content.spanish', 'attr' => array('class' => 'col-xs-12'))) ->add('titleEn', 'text', array('required' => true,'label' => 'label.title.english', 'attr' => array('class' => 'col-xs-12 form-control input-lg'))) ->add(

Overriding the User Admin Form

烈酒焚心 提交于 2019-12-03 15:57:49
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\UserBundle\Admin\Model\UserAdmin arguments: [%sonata_user.model.user.class%] tags: - { name: form

SonataMediaBundle - how to upload images?

不打扰是莪最后的温柔 提交于 2019-12-03 15:46:24
问题 Probably should be titled: "SonataMediaBundle - where's the missing howto?". I've made some admin backend with sonataAdminBundle and sonataDoctrineORMAdminBundle (and some other), most of the things worked as expected, but I left file upload and handling for later, because I thought "how hard that possibly can be?". To make long story short - is there ANY documentation about simplest of things - i.e. having images attached to a post or entry, how to configure sonata admin class, how to

SonataAdminBundle form field query

余生颓废 提交于 2019-12-03 10:08:41
问题 In SonataAdminBundle in Admin class I cannot make an orderBy on ManyToMany field. For example Author and Book. Author can have many books, as well as Book can have many Autors. In link above it is written that I can use a query for a form field. So I could prepare a query that would select authors and irder them by name. How to manage this? How to get EntityManager there in order to create query and pass it through query option? protected function configureFormFields(FormMapper $formMapper) {

Is there any way to determine current action (create or edit) in Sonata\\AdminBundle\\Admin\\Admin::configureFormFields()?

陌路散爱 提交于 2019-12-03 10:03:21
I'd like to create different fields configuration for create and edit actions in Sonata Admin Bundle. Is there any way to determine it except checking $this->getSubject()->getId() in Sonata\AdminBundle\Admin\Admin::configureFormFields() ? Picoss You can also do this: protected function configureFormFields(FormMapper $formMapper) { if ($this->isCurrentRoute('create')) { // CREATE } else { // EDIT } } Roberto with: if($this->getRequest()->get($this->getIdParameter()) == null){ // create } else { // edit } I use this : $creationMode = ($this->id($this->getSubject()))?(false):(true); if (

Sonata Admin Bundle Type Collection Customisation

拥有回忆 提交于 2019-12-03 07:21:36
For example I have 3 entities: Category Subcategory Product In SonataAdminBundle I'd like to be able to add Subcategory while editing Category and Products while editing Subcategory. Following this idea I created fields, but SonataAdminBundle starts playing "Inception" with them. When I open Category I see related Subcategories which contain related Products. How can I cut off "Products" field in this case? Update: My classes (simplified) look like this: // .../CoreBundle/Admin/CategoryAdmin.php protected function configureFormFields(FormMapper $formMapper) { $formMapper ->add('name', null,

Sonataadminbundle: Multiple admin section for same entity

痴心易碎 提交于 2019-12-03 05:46:04
问题 I have entity class Page with column type=integer . When I do: <service id="sonata.admin.pages" class="Main\ProgramBundle\Admin\PageAdmin"> <tag name="sonata.admin" manager_type="orm" group="dashboard" label="Pages"/> <argument /> <argument>Main\ProgramBundle\Entity\Page</argument> <argument>SonataAdminBundle:CRUD</argument> </service> <service id="sonata.admin.groups" class="Main\ProgramBundle\Admin\GroupAdmin"> <tag name="sonata.admin" manager_type="orm" group="stories" label="Groups"/>

Nested collection fields in Sonata Admin (2.3)

混江龙づ霸主 提交于 2019-12-03 05:31:13
I'm having problems creating my form for creating a course. This is a part of my database scheme for which I'm trying to create a form: So which I'm trying to do is create a course where I can create sessions and dates (moment) attached to that session. It should look something like this: In my CourseAdmin class I have: protected function configureFormFields(FormMapper $formMapper) { $formMapper ->add('name', 'text', array('label' => 'Naam')) ->add('description', 'textarea', array('label' => 'Beschrijving')) ->add('materials', 'textarea', array('label' => 'Benodigde materialen')) ->add(