From 92f90bb6c21bb690ff703eafd1013e5f7213033d Mon Sep 17 00:00:00 2001 From: Victor Bocharsky Date: Thu, 11 Dec 2025 16:26:59 +0100 Subject: [PATCH] Add scripts to the 4th chapter --- sfcasts/multiple-submits.md | 158 +++++++++++++++++++++++++++++++++++- 1 file changed, 156 insertions(+), 2 deletions(-) diff --git a/sfcasts/multiple-submits.md b/sfcasts/multiple-submits.md index dd89865..7b1618d 100644 --- a/sfcasts/multiple-submits.md +++ b/sfcasts/multiple-submits.md @@ -1,4 +1,158 @@ -# Handling Multiple Submit Buttons +# Multiple Submit Buttons -TODO +Alright, we've got our "Create" button working like a charm, but what if we +want a couple of different workflows: "Create and Close" to save the part +and jump back to the list, and "Create and Add Another" to save the part +but stay on the form page for quick data entry. +No worries, Symfony is fully capable of handling this. Let's dive into +the second method of adding buttons to a form using the Form type, +and use it to drive our business logic. + +## Adding a Second Submit Button Inside the Form Type + +First things first, let's tweak the name of our current button in the +`new.html.twig` template to "Create and Close". Now, pop open your Form +type class in `src/Form/StarshipPartType.php`. It's time to drop in a +second button below the fields. Let's add another one using +`->add('createAndAddNew', SubmitType::class)`. This handy +`SubmitType::class` tells Symfony to render it as a `