CoolCMS API

CategoryFormTrait

Company module category add/edit form: a code list for the whole module (typically technologies used in references).

Same as CategoryFormTrait without the "free" flag. Multilingual fields (name, URL, editor info, meta) are per language; the parent category (tree) and the image/icon are not translated. The Api computes the nested-set indexes (lft/rgt/level): save() for a new category, moveSubtree() when the parent changes. The image is saved via $meta and the Api afterSave (creates variants, sets the FK). The skeleton is BasePresenter::createForm().

Table of Contents

Methods

createComponentEditForm()  : Form
addStructureFields()  : void
Structure: parent category (tree), icon CSS class and image/icon.
addTranslationFields()  : void
Multilingual fields, one set per language (`<field>_<langId>`), active per checkbox.
buildCategoryEntity()  : Category
collectImageMeta()  : array<string, mixed>
Builds `$meta` for the save: a new image (base64) and/or the delete flag.
isHrefUnique()  : bool
Validates that the href is unique in the given language among other categories (the edited category is skipped on edit). An empty href (nullable) is not checked.
saveCategoryForm()  : bool
setCategoryFormDefaults()  : void

Methods

addStructureFields()

Structure: parent category (tree), icon CSS class and image/icon.

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

addTranslationFields()

Multilingual fields, one set per language (`<field>_<langId>`), active per checkbox.

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

buildCategoryEntity()

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

collectImageMeta()

Builds `$meta` for the save: a new image (base64) and/or the delete flag.

private collectImageMeta(ArrayHash<string|int, mixed> $values) : array<string, mixed>

The Api creates the Asset (variants) and sets the FK to the category image.

Parameters
$values : ArrayHash<string|int, mixed>
Return values
array<string, mixed>

isHrefUnique()

Validates that the href is unique in the given language among other categories (the edited category is skipped on edit). An empty href (nullable) is not checked.

private isHrefUnique(TextInput $input, int $langId) : bool
Parameters
$input : TextInput
$langId : int
Return values
bool

saveCategoryForm()

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

Search results