CoolCMS API

FormTrait

New complaint form: canonical initialization with `useDomainTranslator()` and bare tree keys.

Table of Contents

Methods

onError()  : void
onSuccess()  : void
Handles a valid submit and creates the complaint through the Api.
createComponentForm()  : Form
addItemFields()  : void
Adds one row per item: a checkbox plus a quantity select from 1 to the remaining quantity, only for items with something remaining.
addSolutionField()  : void
errorMessageKey()  : string
Maps the Api `errorCode` to a message key; an unknown code gets the generic message.

Methods

onSuccess()

Handles a valid submit and creates the complaint through the Api.

public onSuccess(Form $form, ArrayHash $values) : void

IMPORTANT: the parameter must be typed ArrayHash, not mixed. Nette\Forms\Form::invokeHandlers() reads the declared type of the second handler parameter by reflection and passes it as $returnType to getValues(), which then calls new ReflectionClass($returnType); mixed crashes at runtime with a ReflectionException, although the Form::$onSuccess PHPDoc says callable(Form, mixed).

Parameters
$form : Form
$values : ArrayHash

addItemFields()

Adds one row per item: a checkbox plus a quantity select from 1 to the remaining quantity, only for items with something remaining.

private addItemFields(Form $form) : void
Parameters
$form : Form

addSolutionField()

private addSolutionField(Form $form) : void
Parameters
$form : Form

errorMessageKey()

Maps the Api `errorCode` to a message key; an unknown code gets the generic message.

private errorMessageKey(string|null $errorCode) : string
Parameters
$errorCode : string|null
Return values
string
On this page

Search results