CoolCMS API

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->replyTo
  • getModalTarget(): string
  • createModalContent(): string
  • createSuccessContent(): string
  • createModalEvent(string $content, array $extraOptions = []): ModalWindowEvent
  • initializeRender(): void
  • isLoginRequired(): 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
Form

onFormError()

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
On this page

Search results