I have some troubles with my Symfony Form. In my first controller, I render a form like this:
$annonce = new Annonce();
$formBuilder = $this->createFormBuilder($annonce);
$formBuilder
->add('title', 'text')
->add('valider', 'submit');
$form = $formBuilder->getForm();
$request = $this->get('request');
if ($request->getMethod() == 'POST') {
$form->bind($request);
$response = $this->forward('ProjectMainBundle:Commande:new', array(
'annonce' => $form["title"]
));
return $response;
}
And I print the form in the view like this:
<form method="post" {{ form_enctype(form) }}>
{{ form_row(form.title, {'attr': {'value': entity.mytext }}) }}
<input type="submit" class="btn btn-primary" />
</form>
That's give:
<form method="post">
<div>
<label class="required" for="form_title">Title</label>
<input id="form_title" type="text" value="11" required="required" name="form[title]">
</div>
<input class="btn btn-primary" type="submit">
</form>
So when I submit it, I got the warning
"An exception has been thrown during the rendering of a template ("Catchable Fatal Error: Object of class Symfony\Component\Form\Form could not be converted to string"
I simply want to redirect to the controller "newAction" (that's work), but with the value of the input of my form !
<input id="form_title" type="text" value="11" required="required" name="form[title]">
It seems to I return the form object with
$response = $this->forward('ProjectMainBundle:Commande:new', array(
'annonce' => $form["title"]
));
But how return just the value of the input of the form ?
Big thanks for help