symfony2 / doctrine,使用实体表单类型的自定义值

时间:2013-06-17 13:49:56

标签: forms symfony doctrine one-to-many entities

我对symfony表格有以下问题。

我有两个有一对多关系的权利。广告和发布日期。第二个字段只有两个字段,外键ads_id和release_date是日期时间类型。

在我创建广告的表单上,我想显示包含所有可能日期值的复选框,并且在表单上提交应该创建适当的行。存储在另一个表中的可用日期值,但它们之间没有关系。

我现在有什么

->add('releaseDates', 'choice', array(
        'multiple' => true, 
        'expanded' => true, 
        'choices' => $options['rdl'],
        'constraints' => new Count(array('min' => 1, 'minMessage' => 'Choose at least one release date')),
)

但是在渲染表单时出现了“预期数组”这样的错误。

我也试过其他方法,

->add('releaseDates', 'order_release_dates', array(
    'multiple' => true, 
    'expanded' => true, 
    'class' => 'MyBundle:ReleaseDate', 
    'choices' => $options['rdl'],
    'property' => 'releaseDate',
    'constraints' => new Count(array('min' => 1, 'minMessage' => 'Choose at least one release date')),
)

但仍未取得任何成功“警告:spl_object_hash()期望参数1为对象,字符串为”。

所以我的问题是什么,是否有任何解决方案,或者我应该手动处理提交并创建必要的实体?

0 个答案:

没有答案
相关问题