我尝试使用自己的ImageType配置EasyAdminBundle以在我的ArticleType中上传文件.所以我创建了这个服务app\config\services.yml
:
services: oah_news_form_type_image: class: OAH\NewsBundle\Form\ImageType tags: [ { name: form.type, alias: 'oah_news_form_type_image' } ]
并试图在我的电话中调用它app\config\config.yml
:
easy_admin: entities: Article: class: OAH\NewsBundle\Entity\Article form: fields: - Titre - Auteur - Date - Categorie - { property : 'Image', type : oah_news_form_type_image}
但我有以下错误,我不知道如何解决它:
The type name specified for the service "oah_news_form_type_image" does not match the actual name. Expected "oah_news_form_type_image", given "oah_newsbundle_image"
我的ImageType:
class ImageType extends AbstractType { /** * @param FormBuilderInterface $builder * @param array $options */ public function buildForm(FormBuilderInterface $builder, array $options) { $builder ->add('file', 'file'); } /** * @param OptionsResolverInterface $resolver */ public function setDefaultOptions(OptionsResolverInterface $resolver) { $resolver->setDefaults(array( 'data_class' => 'OAH\NewsBundle\Entity\Image' )); } /** * @return string */ public function getName() { return 'oah_newsbundle_image'; } }
谢谢 !
看来你的别名,你必须匹配return
的getName()
.