我有一个没有课课的表格
class ProfilesSearchType extends AbstractType {
public function buildForm(FormBuilder $builder, array $options)
{
$builder
->add( disabilityType , entity , array(
class => AldenXyzBundle:DisabilityType ,
property => name ,
multiple => true,
expanded => true,
))
;
}
调用控制器
public function listAction()
{
$form = $this->createForm(
new AldenXyzBundleFormTypeProfilesSearchType(), array());
if (isset($_GET[ profile_search ]))
{
$form->bindRequest($request);
$d = $form->getData();
// some stuff here
}
return array(
form => $form->createView()
);
}
How to set all checkboxes from disabilityType as checked by default? The class definition is (I deleted setters and getters)
class DisabilityType {
/**
* @var integer $disabilityTypeId
*
* @ORMColumn(name="disability_type_id", type="integer", nullable=false)
* @ORMId
* @ORMGeneratedValue(strategy="IDENTITY")
*/
private $disabilityTypeId;
/**
* @var string $name
*
* @ORMColumn(name="name", type="string", length=50, nullable=false)
*/
private $name;
/**
* @var Profile
*
* @ORMManyToMany(targetEntity="Profile", mappedBy="disabilityType")
*/
private $profile;
public function __construct()
{
$this->profile = new DoctrineCommonCollectionsArrayCollection();
}
}