score:1

Accepted answer
$form->get('mythings')->getData()

will give you data that you need.

I hope this helps.

score:1

It's an issue with field mapping. the data you're passing into the form needs to be applied to the field you're adding ('mythings') so you have to wrap $data in an array as a value to the key 'mythings'.

For example:

$data=array();
$choices=array(1 => 'A thing', 2 => 'This other thing', 100 => 'That other thing');

$fb=$this->createFormBuilder(array('mythings' => $data));
$fb->add('mythings', 'choice', array(
    'choices' => $choices,
    'required' => false,
    'expanded' => true, 
    'multiple' => true))
   ->add('save', 'submit', array('label' => 'Save'));

$form=$fb->getForm();

score:1

you could try naming the array keys to preserve the actual index

$data=array();
$choices=array('1' => 'A thing', '2' => 'This other thing', '100' => 'That other thing');

$fb=$this->createFormBuilder($data);
$fb->add('mythings', 'choice', array(
        'choices' => $choices,
        'data' => $data,
        'required' => false,
        'expanded' => true, 
        'multiple' => true,
        'mapped' => false))->
    add('save', 'submit', array('label' => 'Save'));
$form=$fb->getForm();

Related Query

More Query from same tag