SonataAdminBundle form field query

笑着哭i 提交于 2019-12-03 00:40:44
Tom

OK, I got it work:

/**
 * @param \Sonata\AdminBundle\Form\FormMapper $formMapper
 * @return void
 */
protected function configureFormFields(FormMapper $formMapper)
{
    $entity = new \MyCompany\MyProjectBundle\Entity\Seria();
    $query = $this->modelManager->getEntityManager($entity)->createQuery('SELECT s FROM MyCompany\MyProjectBundle\Entity\Seria s ORDER BY s.nameASC');

    $formMapper
        ->add('title', 'text')
        ->add('seria', 'sonata_type_model', array('required' => true, 'query' => $query), array('edit' => 'standard'))
        ->add('description', 'textarea',
               array('attr' => array('class' => 'tinymce'), 'required' => false))        
    ;
}

Anything changed about that ? i'm getting a "class does not exist (500 error)" by using this.

Note : it was working back in Symfony 2.1 but not anymore in Symfony 2.2.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!