Skip to content

Instantly share code, notes, and snippets.

Created April 2, 2011 21:42
Show Gist options
  • Save anonymous/899931 to your computer and use it in GitHub Desktop.
Save anonymous/899931 to your computer and use it in GitHub Desktop.
in my controller:
--------------------
$form = SalesForm::create($this->get('form.context'), 'sale', array('em' => $em));
in my SalesForm:
--------------------
class SalesForm extends Form
{
protected function configure()
{
$this->addRequiredOption('em');
$this->add(new TextField('city', array(
'required' => true,
'max_length' => 100,
)));
$this->add(new TextField('sale', array(
'required' => true,
)));
$this->add(new EntityChoiceField('rep_id', array(
'em' => em,
'class' => 'Aware\\SalesBundle\\Entity\\Rep',
'property' => 'name',
'query_builder' => function($repository) {
return $repository->createQueryBuilder('rep');
}
)));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment