diff --git a/sfcasts/metadata.yml b/sfcasts/metadata.yml index 6566d5b..3c322ea 100644 --- a/sfcasts/metadata.yml +++ b/sfcasts/metadata.yml @@ -8,3 +8,6 @@ chapters: handle-form: tutsFirstStep: handle-form-check-if-submitted tutsLastStep: multiple-submits-rename-to-create-and-close + multiple-submits: + tutsFirstStep: multiple-submits-add-new-btn + tutsLastStep: apply-tailwind-form-theme-in-the-template diff --git a/sfcasts/multiple-submits.md b/sfcasts/multiple-submits.md new file mode 100644 index 0000000..094767f --- /dev/null +++ b/sfcasts/multiple-submits.md @@ -0,0 +1,158 @@ +# Handling Multiple Submit Buttons + +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 `