Php SonataNewsBundle-注释-将状态添加到过滤器
SonataNewsBundle CommentAdmin中的默认值为:Php SonataNewsBundle-注释-将状态添加到过滤器,php,symfony,sonata-admin,Php,Symfony,Sonata Admin,SonataNewsBundle CommentAdmin中的默认值为: protected function configureDatagridFilters(DatagridMapper $datagridMapper) { $datagridMapper ->add('name') ->add('email') ->add('message') ; } 在受保护的函数配置FormFields(FormMap
protected function configureDatagridFilters(DatagridMapper $datagridMapper)
{
$datagridMapper
->add('name')
->add('email')
->add('message')
;
}
在受保护的函数配置FormFields(FormMapper$FormMapper)中:
protected function configureFormFields(FormMapper $formMapper)
{
if (!$this->isChild()) {
$formMapper->add('post', 'sonata_type_model_list');
// $formMapper->add('post', 'sonata_type_admin', array(), array('edit' => 'inline'));
}
$commentClass = $this->commentManager->getClass();
$formMapper
->add('name')
->add('email')
->add('url', null, array('required' => false))
->add('message')
->add('status', 'choice', array('choices' => $commentClass::getStatusList(), 'expanded' => true, 'multiple' => false))
;
}
我尝试添加到过滤器:
->add('status', null, array('label' => 'Status'), null, array('expanded' => true, 'multiple' => true))
但这是一个例外:
The options "expanded", "multiple" do not exist.
我也试过:
->添加('status','doctrine\u orm\u callback',数组(
现在显示错误,但select为空。如何添加此列表状态?
我从中得到了一些例子
也许是更好的方法?通过调用add()方法,给出的参数顺序错误。 请尝试以下操作:
$filters->add('status', null, array(), 'choice', array('choices' => $commentClass::getStatusList(), 'expanded' => true, 'multiple' => false))
表单选项设置在第5个参数上
$filters->add('status', null, array(), 'choice', array('choices' => $commentClass::getStatusList(), 'expanded' => true, 'multiple' => false))