CoolCMS API

FormTrait

Table of Contents

Properties

$onError  : array<string|int, callable(Form, static): void>
Signature: function(Form $form, self $component): void
$onSuccess  : array<string|int, callable(Form, ArrayHash, static): void>
$onValidate  : array<string|int, callable(Form, ArrayHash, static): void>
Events for the consumer (presenter / parent control). `ParameterForm` only renders and validates; business logic (save, email, redirect) belongs to whoever instantiates the component.
$fieldBuilder  : ParameterFieldBuilder|null

Methods

beforeSubmitButton()  : void
Hook: a child component may add its own fields before submit (recaptcha, password input, agreement checkbox and similar).
createComponentForm()  : Form
extractParameterValues()  : array<int, array<int, array{value: mixed, value2?: ?string}>>
Helper that extracts form values. Returns only persistable parameters, i.e. not file/image types.
findParameterByKey()  : ParameterInterface|null
getEntityValues()  : array<int, mixed>
Hook: map of entity values for prefill (parameterId => value | value[]).
getFieldBuilder()  : ParameterFieldBuilder
Lazy shared builder of parameter fields, initialized from the resolved engine state (items/groups/context/mode). Entity values are read at the first build (after `setAdvert()`/`setCategoryList()`), as with {@see \App\Core\Form\Parameters\Building\DefaultsTrait::applyDefaults()}.
getSubmitLabel()  : string
Hook: translation key of the submit button caption.
processSubmit()  : void
Hook: internal handling of a successfully validated form. The child builds the entity, passes it to the manager, sets the flash message and handles the redirect or AJAX redraw. Runs before the consumer {@see $onSuccess} callbacks.

Properties

$onError

Signature: function(Form $form, self $component): void

public array<string|int, callable(Form, static): void> $onError = []

$onSuccess

public array<string|int, callable(Form, ArrayHash, static): void> $onSuccess = []

$onValidate

Events for the consumer (presenter / parent control). `ParameterForm` only renders and validates; business logic (save, email, redirect) belongs to whoever instantiates the component.

public array<string|int, callable(Form, ArrayHash, static): void> $onValidate = []

Signature: function(Form $form, ArrayHash $values, self $component): void

Methods

beforeSubmitButton()

Hook: a child component may add its own fields before submit (recaptcha, password input, agreement checkbox and similar).

protected beforeSubmitButton(Form $form) : void
Parameters
$form : Form

extractParameterValues()

Helper that extracts form values. Returns only persistable parameters, i.e. not file/image types.

protected extractParameterValues(ArrayHash $values) : array<int, array<int, array{value: mixed, value2?: ?string}>>

The key is parameterId, the value a list of rows to persist; the handler decides (scalar: 1 row, multiselect: N rows, range: 1 row with value+value2).

Parameters
$values : ArrayHash
Return values
array<int, array<int, array{value: mixed, value2?: ?string}>>

getEntityValues()

Hook: map of entity values for prefill (parameterId => value | value[]).

protected getEntityValues() : array<int, mixed>

Empty by default; a component without an entity (new record) has nothing to prefill.

Return values
array<int, mixed>

getFieldBuilder()

Lazy shared builder of parameter fields, initialized from the resolved engine state (items/groups/context/mode). Entity values are read at the first build (after `setAdvert()`/`setCategoryList()`), as with {@see \App\Core\Form\Parameters\Building\DefaultsTrait::applyDefaults()}.

protected getFieldBuilder() : ParameterFieldBuilder
Return values
ParameterFieldBuilder

getSubmitLabel()

Hook: translation key of the submit button caption.

protected getSubmitLabel() : string
Return values
string

processSubmit()

Hook: internal handling of a successfully validated form. The child builds the entity, passes it to the manager, sets the flash message and handles the redirect or AJAX redraw. Runs before the consumer {@see $onSuccess} callbacks.

protected processSubmit(Form $form, ArrayHash $values) : void
Parameters
$form : Form
$values : ArrayHash
On this page

Search results