简体   繁体   中英

Sonata-admin filters should looks like set of checkboxes, but got error

I am trying to make custom filtering by field described in model like. Filter should look like set of checkboxes with options to choose, not like default select box with 'tags'

/**
 * @var ArrayCollection
 * @ORM\ManyToMany(targetEntity="Industry",inversedBy="companies")
 */
protected $industries;

In admin class i wrote like

/**
 * @param DatagridMapper $datagridMapper
 */
protected function configureDatagridFilters(DatagridMapper $datagridMapper)
{
    $datagridMapper
        ->add('industries', null, [], null, [ 'multiple' => true,'expanded' => true,
            ])
    ;
}

But the only result i got is error

Variable "widget_type" does not exist in SonataAdminBundle:Form:filter_admin_fields.html.twig >at line 33 500 Internal Server Error - Twig_Error_Runtime

Comment this line

    {% set label_attr = label_attr|merge({'class': (label_attr.class ~ ' ' ~ (widget_type != '' ? (multiple ? 'checkbox' : 'radio') ~ '-' ~ widget_type : ''))}) %}

In Sonata-project/admin-bundle/resources/view/Form/filter_admin_fields.html line 36

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM