CoolCMS API

MenuItemFormTrait

Add/edit form of a menu item ({@see MenuItem}), the counterpart of the `edit` rowAction and the add link in the item DataGrid.

It holds the menu membership (menuId), the parent item (parentId, a picker over the same menu), the item's own attributes and translations.

The Api manages the tree indexes (lft/rgt/level): save() computes them for a new item (SaveTrait, insertTreeNode), and after a parent change of an existing item moveSubtree() recomputes the whole subtree. Fine-tuning the order is done by drag and drop in the grid.

The skeleton (save/update/cancel and the return) comes from BasePresenter::createForm(); see also PageFormTrait.

Table of Contents

Methods

createComponentEditForm()  : Form
addMenuItemAttributeFields()  : void
The item's own attributes: link, behavior, HTML attributes, visibility.
addMenuItemTranslationFields()  : void
Per-language fields, one set per language (`<field>_<langId>`), required only when the language is active.
buildMenuItemEntity()  : MenuItem
saveMenuItemForm()  : bool
setMenuItemFormDefaults()  : void
str()  : string
Safely converts mixed to string.
strOrNull()  : string|null
Converts mixed to string or null (an empty string is stored as null).

Methods

addMenuItemAttributeFields()

The item's own attributes: link, behavior, HTML attributes, visibility.

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

addMenuItemTranslationFields()

Per-language fields, one set per language (`<field>_<langId>`), required only when the language is active.

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

buildMenuItemEntity()

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

saveMenuItemForm()

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

str()

Safely converts mixed to string.

private str(mixed $value) : string
Parameters
$value : mixed
Return values
string

strOrNull()

Converts mixed to string or null (an empty string is stored as null).

private strOrNull(mixed $value) : string|null
Parameters
$value : mixed
Return values
string|null
On this page

Search results