php - Symfony set data to multiple choiceType -
i set symfony choicetype value inside controller using this:
$editform->get('userjobtitle')->setdata($job->getjobtitle()->getid());
how multiple choicetype? following method isn't working
$editform->get('userskills')->setdata($job->getskills());
where getskills
function return doctrine collection.
setdata()
method requires array of strings contain values of selected options do:
$usskills = $job->getskills()->getvalues(); $vals = array(); foreach ($usskills $us){ $vals[] = (string)$us->getid(); } $editform->get('userskills')->setdata($vals);
and solved problem
Comments
Post a Comment