dongzuo9096 2014-03-20 19:28
浏览 6
已采纳

在Sonata Admin的实体中包含媒体类型

I'm making an Entity which is called Article, it should have some text, a video and a couple of images. For the latter I'm doing it by allowing the user to create a media and then include the images there, now for the question... how do I relate that media to the article? Do I have a "media list picker" to choose from?

  • 写回答

1条回答 默认 最新

  • douyuan4697 2014-03-22 13:59
    关注

    To include Sonata MediaBundle in the Admin Bundle, you'll need to add for example an Image field to your Article entity.

    /**
     * @ORM\ManyToOne(targetEntity="Application\Sonata\MediaBundle\Entity\Gallery")
     * @ORM\JoinColumns({
     *   @ORM\JoinColumn(name="image", referencedColumnName="id")
     * })
     */
    private $image;
    

    And then refer to it in your ArclicleAdmin :

    ->add('image', 'sonata_type_model_list', array('required' => false))
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 关于CMOS电路图的提问
  • ¥15 Verilog hdl密码锁设计
  • ¥35 基于python的有ssl加密传输的socket聊天室
  • ¥15 数码管亮度控制器设计
  • ¥15 kafka客户端跨网段访问,看日志提示连接的还剩内网地址,且访问不通
  • ¥15 关于c语言代码的问题
  • ¥15 c51单片机控制步进电机
  • ¥20 Visual studio无法检测到设备
  • ¥30 vue 页面窗口放大或者缩小元素会变化
  • ¥15 questasim仿真报错