Skip to content

Commit 9e4a766

Browse files
committed
minor #96 Submit a Form with Multiple Buttons (makraz, weaverryan)
This PR was merged into the main branch. Discussion ---------- Submit a Form with Multiple Buttons | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | Tickets | Fix #95 | License | MIT Commits ------- eeb57df slightly shortening example 91bb857 Submit a Form with Multiple Buttons
2 parents 7ff7772 + eeb57df commit 9e4a766

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/Turbo/README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,28 @@ _also_ changes the redirect status code from 302 (the default) to 303
155155
(`HTTP_SEE_OTHER`). That's not required for Turbo Drive, but 303 is "more correct"
156156
for this situation.
157157

158+
> **NOTE:**
159+
> When your form contains more than one submit button and, you want to check which of the buttons was clicked
160+
> to adapt the program flow in your controller. You need to add a value to each button because
161+
> Turbo Drive doesn't send element with empty value:
162+
163+
```php
164+
$builder
165+
// ...
166+
->add('save', SubmitType::class, [
167+
'label' => 'Create Task',
168+
'attr' => [
169+
'value' => 'create-task'
170+
]
171+
])
172+
->add('saveAndAdd', SubmitType::class, [
173+
'label' => 'Save and Add',
174+
'attr' => [
175+
'value' => 'save-and-add'
176+
]
177+
]);
178+
```
179+
158180
#### More Turbo Drive Info
159181

160182
[Read the Turbo Drive documentation](https://turbo.hotwire.dev/handbook/drive) to learn about the advanced features offered

0 commit comments

Comments
 (0)