I understand how to pass a variable from a controller to a form through the createForm
method, but what if I need to pass that value to a form embedded in the form I am called createForm on? I never explicitly call createForm anywhere on the embedded form, so how am I supposed to get that value to it? It is worth noting the value I am trying to pass is available through a service, but I can't call $this->get('serviceName')->getValue()
because I am not in a controller. For reference, this is how I get the value to the parent form, note how I do it through the createForm method, not the contructor:
//in a controller
$form = $this->createForm(new FormType(), $formObject, array('value' => $value));