CoolCMS API

CurrencyFormTrait

Add/edit form of a currency.

BasePresenter::createForm() provides the skeleton. Flat entity (translations are separate fields): identification, credit rate or price, number formatting, symbol positions and global activation (activated, a toggle in the header).

Table of Contents

Constants

SYMBOL_POSITIONS  : mixed = ['a', 'b']
Symbol position: `a` = after the value, `b` = before the value (legacy values).

Methods

createComponentEditForm()  : Form
addTranslationFields()  : void
Adds the multilingual fields: per language translation of the name, description and the pluralized label after the amount (`name_<langId>` etc.). All optional (fallback to the flat currency columns), active per the `active_<langId>` checkbox. `shortcut` is not translated: it is the currency key for payment gateways and stays in the identification group.
applyCurrencyTranslations()  : void
Applies the multilingual form fields to the currency translation entities: updates an existing translation and creates a missing one (object-graph save through the Api bridge, cascade persist on `translations`).
floatVal()  : float
Converts a mixed form value to float safely.
saveCurrencyForm()  : bool
Saves the form data; {@see \App\Core\Base\Admin\BasePresenter::createForm()} handles the redirect.
setCurrencyFormDefaults()  : void

Constants

SYMBOL_POSITIONS

Symbol position: `a` = after the value, `b` = before the value (legacy values).

private mixed SYMBOL_POSITIONS = ['a', 'b']

Methods

addTranslationFields()

Adds the multilingual fields: per language translation of the name, description and the pluralized label after the amount (`name_<langId>` etc.). All optional (fallback to the flat currency columns), active per the `active_<langId>` checkbox. `shortcut` is not translated: it is the currency key for payment gateways and stays in the identification group.

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

applyCurrencyTranslations()

Applies the multilingual form fields to the currency translation entities: updates an existing translation and creates a missing one (object-graph save through the Api bridge, cascade persist on `translations`).

private applyCurrencyTranslations(Currency $currency, ArrayHash<string|int, mixed> $values) : void
Parameters
$currency : Currency
$values : ArrayHash<string|int, mixed>

floatVal()

Converts a mixed form value to float safely.

private floatVal(mixed $value) : float
Parameters
$value : mixed
Return values
float

saveCurrencyForm()

Saves the form data; {@see \App\Core\Base\Admin\BasePresenter::createForm()} handles the redirect.

private saveCurrencyForm(ArrayHash<string|int, mixed> $values) : bool
Parameters
$values : ArrayHash<string|int, mixed>
Return values
bool
On this page

Search results