Skip to content

[FrameworkBundle] Replace render() with new renderForm() in form documentation #15105

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions form/direct_submit.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ control over when exactly your form is submitted and what data is passed to it::
}
}

return $this->render('task/new.html.twig', [
'form' => $form->createView(),
]);
return $this->renderForm('task/new.html.twig', $form);
}

.. tip::
Expand Down
5 changes: 1 addition & 4 deletions form/dynamic_form_modification.rst
Original file line number Diff line number Diff line change
Expand Up @@ -534,10 +534,7 @@ your application. Assume that you have a sport meetup creation controller::
// ... save the meetup, redirect etc.
}

return $this->render(
'meetup/create.html.twig',
['form' => $form->createView()]
);
return $this->renderForm('meetup/create.html.twig', $form);
}

// ...
Expand Down
4 changes: 1 addition & 3 deletions form/form_collections.rst
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,7 @@ In your controller, you'll create a new form from the ``TaskType``::
// ... do your form processing, like saving the Task and Tag entities
}

return $this->render('task/new.html.twig', [
'form' => $form->createView(),
]);
return $this->renderForm('task/new.html.twig', $form);
}
}

Expand Down
13 changes: 7 additions & 6 deletions forms.rst
Original file line number Diff line number Diff line change
Expand Up @@ -277,12 +277,15 @@ to build another object with the visual representation of the form::

$form = $this->createForm(TaskType::class, $task);

return $this->render('task/new.html.twig', [
'form' => $form->createView(),
]);
return $this->renderForm('task/new.html.twig', $form);
}
}

.. versionadded:: 5.3

The ``renderForm`` method was introduced in Symfony 5.3, allowing to
return 422 HTTP status code if an invalid form is submitted.

Then, use some :ref:`form helper functions <reference-form-twig-functions>` to
render the form contents:

Expand Down Expand Up @@ -405,9 +408,7 @@ written into the form object::
return $this->redirectToRoute('task_success');
}

return $this->render('task/new.html.twig', [
'form' => $form->createView(),
]);
return $this->renderForm('task/new.html.twig', $form);
}
}

Expand Down