更改ListMapper Sonata管理员中的字段CSS



我想在listMapper中修改" benefice"字段的样式。

    protected function configureListFields(ListMapper $listMapper)
    {
        $listMapper
            ->addIdentifier('id')
            ->add('date')
            ->add("nombreMatch")
            ->add('cote')
            ->add('mise')
            ->add('gain')
            ->add('benefice',null,array(
            'attr' => array('style' => 'color:red;'),
            ));
    }   
}

我使用" attr"属性,但确实可以工作。我还尝试" header_style"属性,并且确实可以。

如果有人有解决方案,

感谢您的帮助:(

您可以像我在这里一样传递第三参数的自定义tempalate,或者您可以尝试通过header_style而不是attr,如这里所述。

我找到了解决方案,谢谢!

对于其他有同样问题的人:

 protected function configureListFields(ListMapper $listMapper)
    {
        $listMapper
            ->addIdentifier('id', null ,[
                'header_style' => 'width: 14%',    
            ])
            ->add('date', null ,[
                'header_style' => 'width: 14%',    
            ])
            ->add("nombreMatch", null ,[
                'header_style' => 'width: 14%',    
            ])
            ->add('cote', null ,[
                'header_style' => 'width: 14%',    
            ])
            ->add('mise', null ,[
                'header_style' => 'width: 14%',    
            ])
            ->add('gain', null ,[
                'header_style' => 'width: 14%',    
            ])
           ->add('benefice', null, array('template' => '@SonataAdmin/CRUD/Special/benefice_field_list.html.twig'))
        ;
    }
{% extends '@SonataAdmin/CRUD/base_list_field.html.twig' %}
{% block field%}
    <div>
        <strong>{{ object.benefice }}</strong>
    </div>
{% endblock %}

最新更新