diff --git a/Documentation/Global/Form/Index.rst b/Documentation/Global/Form/Index.rst index de86877..d12a71f 100644 --- a/Documentation/Global/Form/Index.rst +++ b/Documentation/Global/Form/Index.rst @@ -44,7 +44,7 @@ data objects. For example, user could add a comment in such a form: .. literalinclude:: _codesnippets/_CommentForm.html - :caption: packages/my_extension/Resources/Private/Templates/Comment/_CommentForm.html + :caption: packages/my_extension/Resources/Private/Templates/Comment/CommentForm.html The Extbase Controller action displaying the form then creates the Domain object and passes it to the view. In the Fluid template above we use argument diff --git a/Documentation/Global/Form/Submit.rst b/Documentation/Global/Form/Submit.rst index 70c71dc..0349b65 100644 --- a/Documentation/Global/Form/Submit.rst +++ b/Documentation/Global/Form/Submit.rst @@ -9,31 +9,85 @@ Form.submit ViewHelper `` .. typo3:viewhelper:: form.submit :source: ../../Global.json - :display: tags,description,gitHubLink,arguments + :display: tags + :noindex: + +Creates a submit button (``) within a +`Form ViewHelper `_. + +.. note:: + If you you need a ` +When you want to offer different actions, it can be helpful to use multiple +submit buttons with different labels: -Output:: +.. tabs:: - + .. group-tab:: Fluid + + .. literalinclude:: _codesnippets/_FormSubmitMultiple.html + :caption: packages/my_extension/Resources/Private/Templates/Comment/Edit.html + + .. group-tab:: Controller + + The controller action can then look like this: + + .. literalinclude:: _codesnippets/_SubmitMultipleController.php + :caption: packages/my_extension/Classes/Controller/CommentController.php + +.. note:: + All rendered buttons will be rendered as ``. + If you need a button with a different type than "submit", use the + `Form.button ViewHelper `_ + instead. + +.. _typo3-fluid-form-submit-arguments: + +Arguments of the form.submit ViewHelper +======================================= + +.. include:: /_Includes/_ArbitraryArguments.rst.txt + +.. typo3:viewhelper:: form.submit + :source: /Global.json + :display: arguments-only diff --git a/Documentation/Global/Form/_codesnippets/_FormSubmit.html b/Documentation/Global/Form/_codesnippets/_FormSubmit.html new file mode 100644 index 0000000..69d8ad3 --- /dev/null +++ b/Documentation/Global/Form/_codesnippets/_FormSubmit.html @@ -0,0 +1,8 @@ + + + + + + + diff --git a/Documentation/Global/Form/_codesnippets/_FormSubmitMultiple.html b/Documentation/Global/Form/_codesnippets/_FormSubmitMultiple.html new file mode 100644 index 0000000..0b6de0a --- /dev/null +++ b/Documentation/Global/Form/_codesnippets/_FormSubmitMultiple.html @@ -0,0 +1,10 @@ + + + + + + + + + diff --git a/Documentation/Global/Form/_codesnippets/_SubmitController.php b/Documentation/Global/Form/_codesnippets/_SubmitController.php new file mode 100644 index 0000000..108b94f --- /dev/null +++ b/Documentation/Global/Form/_codesnippets/_SubmitController.php @@ -0,0 +1,26 @@ +commentRepository->update($comment); + $this->addFlashMessage('Your comment was saved'); + return $this->redirect('show'); + } + + // Other actions +} diff --git a/Documentation/Global/Form/_codesnippets/_SubmitMultipleController.php b/Documentation/Global/Form/_codesnippets/_SubmitMultipleController.php new file mode 100644 index 0000000..52a5662 --- /dev/null +++ b/Documentation/Global/Form/_codesnippets/_SubmitMultipleController.php @@ -0,0 +1,45 @@ +addFlashMessage( + 'Your comment was NOT saved, you pressed the cancel button', + 'Attention', + ContextualFeedbackSeverity::WARNING, + ); + return $this->redirect('show'); + } + if ($spellingButton) { + if (!$this->mySpellCheckService->check($comment->getMessage())) { + $this->addFlashMessage('There are spelling errors. '); + } + return $this->redirect('edit', null, null, ['comment' => $comment]); + } + // Form was submitted by submit button or for example by JavaScript + $this->commentRepository->update($comment); + $this->addFlashMessage('Your comment was saved'); + return $this->redirect('show'); + } + + // Other actions +}