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
createComponentEditForm()
protected
createComponentEditForm() : Form
Return values
FormaddMenuItemAttributeFields()
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
MenuItemsaveMenuItemForm()
private
saveMenuItemForm(ArrayHash<string|int, mixed> $values) : bool
Parameters
- $values : ArrayHash<string|int, mixed>
Return values
boolsetMenuItemFormDefaults()
private
setMenuItemFormDefaults(Form $form) : void
Parameters
- $form : Form
str()
Safely converts mixed to string.
private
str(mixed $value) : string
Parameters
- $value : mixed
Return values
stringstrOrNull()
Converts mixed to string or null (an empty string is stored as null).
private
strOrNull(mixed $value) : string|null
Parameters
- $value : mixed