symfony-sonata

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' =

Sonata Media Bundle - how to write custom provider?

限于喜欢 提交于 2019-12-03 20:21:55
There is an example in the official documentation about how to write custom provider, but it doesn't work. My question is: what is the best way to write custom provider, especially how to write and register provider as a new service? When I try to use this code from documentation, I get errors about type of arguments. What does mean empty argument? Thank you. After some investigation, the following code works: Register provider as a service: // src/Application/Sonata/MediaBundle/Resources/config/services.yml parameters: application_sonata_media.custom_class: Application\Sonata\MediaBundle

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) {

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,

How to display the current picture above the upload field in SonataAdminBundle?

落爺英雄遲暮 提交于 2019-12-03 06:38:42
问题 I am using SonataAdminBundle (with Doctrine2 ORM) and I have successfully added a file upload feature to my Picture model. I would like, on the Show and Edit pages, to display a simple <img src="{{ picture.url }} alt="{{ picture.title }} /> tag just above the relevant form field (provided that the Picture being edited is not new, of course), so that the user may see the current photo, and decide whether to change it or not. After hours of research, I've been unable to figure out how to do it.

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(

How to install SonataDoctrineMongoDBAdminBundle properly?

走远了吗. 提交于 2019-12-03 03:40:42
I am really getting nervous because of lacking of enough resource for installing SonataDoctrineMongoDBAdminBundle and it's dependencies like sonataUserBundle. I have been trying to install this bundle for 15 days. I did everyting agaian and again what telling in sonata's official page. But it does not work properly. After extending sonataUserBundle as ApplicationUserBundle my final documents are: User.php <?php /** * This file is part of the <name> project. * * (c) <yourname> <youremail> * * For the full copyright and license information, please view the LICENSE * file that was distributed