FormTrait
Forms of the comment thread component.
Requires in the host class:
$this->modalRegistry(ModalRegistry)$this->eventDispatcher(EventDispatcher)$this->commentManager(CommentManager)$this->threadId$this->translator$this->translatorDomain$this->replyTogetModalTarget(): stringcreateModalContent(): stringcreateSuccessContent(): stringcreateModalEvent(string $content, array $extraOptions = []): ModalWindowEventinitializeRender(): voidisLoginRequired(): bool
Table of Contents
Methods
- createComponentReplyForm() : Form
- Reply form (in the modal).
- onFormError() : void
- Validation errors: the modal is filled from the registry, so its content is rebuilt with the errors (the template lists `$form->errors`, field errors included). Without it an AJAX submit with an empty name or text ended with no response at all.
- onSubmit() : void
- Form submit handler.
- handleSubmitError() : void
- Handles a submit error.
- handleSubmitSuccess() : void
- Handles a successful submit.
- updateModalContent() : void
- Updates the modal content.
Methods
createComponentReplyForm()
Reply form (in the modal).
public
createComponentReplyForm() : Form
Return values
FormonFormError()
Validation errors: the modal is filled from the registry, so its content is rebuilt with the errors (the template lists `$form->errors`, field errors included). Without it an AJAX submit with an empty name or text ended with no response at all.
public
onFormError(Form $form) : void
Parameters
- $form : Form
onSubmit()
Form submit handler.
public
onSubmit(Form $form, ArrayHash $values) : void
Parameters
- $form : Form
- $values : ArrayHash
handleSubmitError()
Handles a submit error.
private
handleSubmitError(Form $form, string $transDomain[, Result|null $result = null ]) : void
Parameters
- $form : Form
- $transDomain : string
- $result : Result|null = null
handleSubmitSuccess()
Handles a successful submit.
private
handleSubmitSuccess(Form $form) : void
Parameters
- $form : Form
updateModalContent()
Updates the modal content.
private
updateModalContent(string $content) : void
Parameters
- $content : string