【问题标题】:set checked attribute for simple checkbox field为简单的复选框字段设置选中属性
【发布时间】:2014-03-12 09:41:33
【问题描述】:

我有以下代码,我尝试在渲染时预先选择复选框的第一个和第二个选项。但是,这不起作用。谁能帮我解释一下为什么?

  $builder->add('preferredContactTypes', 'entity', array('class' => 'AppMainBundle:ContactType', 'property' => 'type', 'multiple' => true, 'expanded' => true, 'mapped' => false, 'data' => array(1,2)))

【问题讨论】:

    标签: php forms symfony


    【解决方案1】:

    实体数据字段期望传递的对象不是整数,

    看到这一行:

    'data'=>$em->getReference("TestGeneralBundle:Sucursal",3)

    来自这个问题:

    Symfony2 Setting a default choice field selection

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-01-10
      • 2018-11-03
      相关资源
      最近更新 更多