I create a form when calling this route:
/**
* @Route("/product/{id}.html")
* @Template()
*/
public function indexAction($id) {
$form = $this->createForm(new AssessmentType());
return array(
'bewertungform' => $form->createView(),
'angebot' => $this->loadAngebot($id)
);
}
Then I want to set the value of a field from this form with the $id. Can I do this in this Action for Example like something $form->setValue('productid',$id)?
Here is my AssessmentType Class:
..../**
* @param FormBuilderInterface $builder
* @param array $options
*/
public function buildForm(FormBuilderInterface $builder, array $options) {
$builder
->add('stars', 'choice', array('choices' => array('1' => '1 star', '2' => '2 stars', '3' => '3 stars', '4' => '4 stars', '5' => '5 stars')))
->add('comment')
->add('productid')
;
}....