Reputation: 8855
In my form i have a simple
<select multiple="multiple" name="action[files][]" id="action_files"></select>
outputed by :
$builder->add('files', 'choice', array('multiple' => true, 'required' => false));
the setFiles()
is working, but when displaying an existent record, the getFiles()
does not work.
Here's the getter :
public function getFiles()
{
$array = array();
$documents = $this->getDocuments();
foreach ($documents as $document) {
$array[$document->getFilename()] = $document->getFilename();
}
return $array;
}
It'll output :
array(1) { ["slide1.jpg"]=> string(10) "slide1.jpg" }
But the select is empty.
How can i achieve that please ?
Upvotes: 0
Views: 312
Reputation: 4841
You did not pass the "choices" option to the choice field.
Upvotes: 1