CoolCMS API

RegionFormTrait

Add/edit form of a region.

The skeleton comes from BasePresenter::createForm(), multilingual fields and conversions from AdminFormHelpersTrait.

Translated: name, href (manual only for a country or root, otherwise regenerated from the path); meta is not edited. Untranslated: key (ISO, 2 characters), isCountry, main, active (header toggle). The grid is flat, so the tree is not enabled despite lft/rgt.

Table of Contents

Methods

createComponentEditForm()  : Form
addSettingsFields()  : void
Settings: parent region (picker), ISO key, country/main/active flags.
addTranslationFields()  : void
Multilingual fields: name and address per language (`name_<langId>`, `href_<langId>`), active by checkbox.
buildRegionEntity()  : Region
saveRegionForm()  : bool
Saves the form data. The redirect is done by {@see \App\Core\Base\Admin\BasePresenter::createForm()}.
setRegionFormDefaults()  : void

Methods

addSettingsFields()

Settings: parent region (picker), ISO key, country/main/active flags.

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

addTranslationFields()

Multilingual fields: name and address per language (`name_<langId>`, `href_<langId>`), active by checkbox.

private addTranslationFields(Form $form) : void

A person enters the address (slug) only for a country or root; descendants inherit it as a prefix and Api afterSave regenerates the whole subtree. For a region with a parent the field is read-only: its href is built from the parent path and a manual value would be overwritten on save anyway.

Parameters
$form : Form

buildRegionEntity()

private buildRegionEntity(ArrayHash<string|int, mixed> $values) : Region
Parameters
$values : ArrayHash<string|int, mixed>
Return values
Region

saveRegionForm()

Saves the form data. The redirect is done by {@see \App\Core\Base\Admin\BasePresenter::createForm()}.

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

Search results