sonata-admin

show total amount of orders on the top of a sonata admin list

浪子不回头ぞ 提交于 2019-12-13 08:58:30
问题 After filtering for a particular criteria, display total of the sales transaction amounts on top of the page. This should be total of all the pages if pages are more than one. Can someone guide me how to do this 回答1: We did it in the following manner and it is working like a charm Step 1 : Added two methods in orderAdmin public function getTemplate($name) { if($name == 'list') { return 'AppBundle:OrderAdmin:list.html.twig'; } return parent::getTemplate($name); stub } public function getSumOf(

Use sonata_type_collection inside custom type

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-13 08:21:22
问题 What I want to do is add sonata_type_collection to my custom formType. Normal way is add sonata_collection_type to $formMaper inside AdminClass like: protected function configureFormFields(FormMapper $formMapper) { $formMapper->add('elements, 'sonata_type_collection', array( 'some_options' => 'options' )) } It work perfect, but i have my custom form type, and when i defined it like: public function buildForm(FormBuilderInterface $builder, array $options) { $formMapper->add('elements, 'sonata

Sonata Admin Bundle filter show entity from role user

倖福魔咒の 提交于 2019-12-13 07:42:54
问题 I'm trying to develop a dashboard with the SonataAdminBundle, which displays some entities depending on the role of the user. For instance, if the connected user has the ROLE_SUPER_ADMIN , all entities should be shown. But if the user is ROLE_USER , only a determinated entity should be shown, not all of them. Is it possible do it in the service declaration of the entity? 回答1: for future reference the trick is to use createQuery and permanentParamters in Sonata to be able to enforce filters. I

Sonata Admin: Boolean selectbox for boolean properties

余生长醉 提交于 2019-12-13 02:24:10
问题 I have defined a boolean property in my Entity: /** * @var boolean * @Assert\Type(type="bool") * @ORM\Column(name="is_managed", type="boolean", nullable=true, options={"default": true}) */ protected $isManaged = true; When I use it in the sonata admin bundle it just generates an select box with values "1" and "2" - I expected "true" or "false" selection. $datagridMapper ->add('description') ->add('isManaged', 'doctrine_orm_boolean') generates the code: <select id="filter_isManaged_value" name

Sonata Admin date choice wrapping

丶灬走出姿态 提交于 2019-12-13 02:24:08
问题 I'm (obviously) new to Symfony/Sonata, I have a problem where Sonata admin is wrapping my date choice onto 3 lines. php: $form = $this->createFormBuilder($statsForm) ->add('startDate', 'date', array('years' => range(2015, date('Y')), 'format' => 'y-M-d', 'widget' => 'choice')) ->add('endDate', 'date', array('years' => range(2015, date('Y')), 'format' => 'y-M-d', 'widget' => 'choice')) ->getForm(); twig: {{ form_start(form) }} <div class="col-md-3"> {{ form_widget(form) }} </div> {{ form_end

SonataAdminBundle custom group icon

此生再无相见时 提交于 2019-12-12 16:11:46
问题 I'm using SonataAdminBundle to generate a CRUD for my Page entity. With the yaml file bellow the menu is displayed in the sidebar. I would like to change the group default icon which is "fa fa-folder". But I don't find the option to do it. sonata.admin.page: class: FM\AppBundle\Admin\Page\Page tags: - { name: sonata.admin, manager_type: orm, group: "CMS", label: "Pages" } arguments: - ~ - FM\AppBundle\Entity\Page\Page - ~ 回答1: "icon" option: icon: "<i class=\"fa fa-folder\"></i>" In your

SonataMediaBundle: How to add svg file extension

柔情痞子 提交于 2019-12-12 12:09:59
问题 I need to add .svg file extension to my configuration. At the moment in my project I have other extensions as (pdf, images) I made the following changes Added a new svg_file to the context Added the file provider (In the end of configuration file) Added the svg in allowed_extensions Added the image/svg+xml in allowed_mime_types Now, I can upload the svg file but the problem is that the user can upload other file extensions for example pdf etc.. How can avoid it? Or find a proper way for the

Dropdown Ajax onchange SonataAdminBundle Symfony2 Issue

守給你的承諾、 提交于 2019-12-12 11:34:04
问题 I am trying to implement onchange dropdown in SonataAdminBundle. My Entity is like class BuilderHomePage { /** * @var integer * * @ORM\Column(name="id", type="integer", nullable=false) * @ORM\Id * @ORM\GeneratedValue(strategy="IDENTITY") */ private $id; /** * @var \Hello\FrontendBundle\Entity\MtContentType * * @ORM\ManyToOne(targetEntity="Hello\FrontendBundle\Entity\MtContentType") * @ORM\JoinColumns({ * @ORM\JoinColumn(name="content_type_id", referencedColumnName="id") * }) */ private

set role for users in edit form of sonata admin

微笑、不失礼 提交于 2019-12-12 09:46:25
问题 I'm using Symfony 2.1 for a project. I use the FOSUserBundle for managing users & SonataAdminBundle for administration usage. I have some questions about that: As an admin, I want to set roles from users in users edit form. How can I have access to roles in role_hierarchy ? And how can I use them as choice fields so the admin can set roles to users? When I show roles in a list, it is shown as string like this: [0 => ROLE_SUPER_ADMIN] [1 => ROLE_USER] How can I change it to this? ROLE_SUPER

SonataAdminBundle embebed form validation error

梦想的初衷 提交于 2019-12-12 04:15:55
问题 I have an admin class, which included another admin class. Symfony 2.7.9 Sonata Admin Bundle 2.3.7 I have it structured in tabs, and the problem is that when there is a validation error in any of the fields of the embedded form is not marked in any way the tab where it is located. This is my example code: Entity Products.php <?php namespace AppBundle\Entity; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\ORM\Mapping as ORM; use Symfony\Component\Validator\Constraints as Assert;