add custom options to a form

73 Views Asked by At

I'd like to pass an option to my form so I did this:

            $builder
                ->add('pays', 'collection', array(
                        'type' => new PaysType(),
                        'em' => $this->em,
                        'allow_add' => true,
                )
              );

Although I added em to my form PaysType I got this error: he option "em" does not exist

  public function getDefaultOptions(array $options)
  {
      $options = parent::getDefaultOptions($options);
      $options['em'] = '';
      return $em;
  }

Any ideas?

1

There are 1 best solutions below

0
nurikabe On BEST ANSWER

getDefaultOptions() should return the options array but you are returning $em. I think that may be your only problem.