-
Notifications
You must be signed in to change notification settings - Fork 24
[TASK] Update form ViewHelper page #112
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace MyVendor\MyExtension\Domain\Model; | ||
|
|
||
| use TYPO3\CMS\Extbase\Annotation\Validate; | ||
| use TYPO3\CMS\Extbase\DomainObject\AbstractEntity; | ||
|
|
||
| class Comment extends AbstractEntity | ||
| { | ||
| #[Validate(['validator' => 'EmailAddress'])] | ||
| protected string $email = ''; | ||
|
|
||
| #[Validate(['validator' => 'StringLength', 'options' => ['maximum' => 500]])] | ||
| protected string $content = ''; | ||
|
|
||
| // Getters and setters ... | ||
| } |
39 changes: 39 additions & 0 deletions
39
Documentation/Global/Form/_codesnippets/_CommentController.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace MyVendor\MyExtension\Controller; | ||
|
|
||
| use Psr\Http\Message\ResponseInterface; | ||
| use T3docs\BlogExample\Domain\Model\Comment; | ||
| use T3docs\BlogExample\Domain\Repository\CommentRepository; | ||
| use TYPO3\CMS\Extbase\Annotation\IgnoreValidation; | ||
| use TYPO3\CMS\Extbase\Mvc\Controller\ActionController; | ||
|
|
||
| class CommentController extends ActionController | ||
| { | ||
| public function __construct( | ||
| protected readonly CommentRepository $commentRepository, | ||
| ) {} | ||
|
|
||
| #[IgnoreValidation(['argumentName' => 'newComment'])] | ||
| public function commentFormAction(?Comment $newComment = null): ResponseInterface | ||
| { | ||
| if ($newComment === null) { | ||
| $newComment = new Comment(); | ||
| $newComment->setDate(new \DateTime()); | ||
| } | ||
| // The assigned object will be used in argument object | ||
| $this->view->assign('newComment', $newComment); | ||
| return $this->htmlResponse(); | ||
| } | ||
|
|
||
| public function createAction( | ||
| // This parameter must have the same name as argument `objectName` of f:form | ||
linawolf marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| Comment $comment, | ||
| ): ResponseInterface { | ||
| $this->commentRepository->add($comment); | ||
| $this->addFlashMessage('Comment was saved'); | ||
| return $this->redirect('show'); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| <html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers" | ||
| data-namespace-typo3-fluid="true"> | ||
| <f:form action="create" controller="Comment" objectName="comment" object="{newComment}" method="post"> | ||
| <div> | ||
| <label for="tx-blogexample-email">E-Mail::</label> | ||
| <f:form.textfield property="email" type="email" id="tx-blogexample-email"/> | ||
| </div> | ||
| <div> | ||
| <label for="tx-blogexample-content">Message:</label> | ||
| <f:form.textarea property="content" id="tx-blogexample-content" rows="8" cols="46"/> | ||
| </div> | ||
| <div> | ||
| <f:form.submit class="button" value="Submit"/> | ||
| </div> | ||
| </f:form> | ||
| </html> |
9 changes: 9 additions & 0 deletions
9
Documentation/Global/Form/_codesnippets/_PlainParameterForm.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| <f:form action="search" method="post" pageUid="{settings.targetPid}"> | ||
| <div> | ||
| <label for="sword">Search:</label> | ||
| <f:form.textfield name="search[sword]" value="{sword}" id="sword" /> | ||
| </div> | ||
| <div> | ||
| <f:form.submit name="search[submitButton]" value="Submit" /> | ||
| </div> | ||
| </f:form> |
17 changes: 17 additions & 0 deletions
17
Documentation/Global/Form/_codesnippets/_SearchController.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace MyVendor\MyExtension\Controller; | ||
|
|
||
| use Psr\Http\Message\ResponseInterface; | ||
| use TYPO3\CMS\Extbase\Mvc\Controller\ActionController; | ||
|
|
||
| class SearchController extends ActionController | ||
| { | ||
| public function searchAction(array $search = []): ResponseInterface | ||
| { | ||
| // TODO: implement search | ||
| return $this->htmlResponse(); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| .. admonition:: Allows arbitrary arguments | ||
|
|
||
| This ViewHelper allows you to pass arbitrary arguments not defined below | ||
| directly to the HTML tag created. This includes custom `data-` arguments. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| .. attention:: | ||
| .. versionchanged:: 12.0 | ||
| The f:form ViewHelpers can only be used within the Extbase context. | ||
|
|
||
| In a non-Extbase context, for example within a | ||
| `FLUIDTEMPLATE <https://docs.typo3.org/permalink/t3tsref:cobj-template>`_ | ||
| Use plain HTML `<form>` and `<input>` tags. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.