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

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -