Skip to content

Instantly share code, notes, and snippets.

@cordoval
Forked from anonymous/gist:899931
Created April 2, 2011 21:45
Show Gist options
  • Save cordoval/899933 to your computer and use it in GitHub Desktop.
Save cordoval/899933 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' or $em, // either one of them....
'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