CategoryFormTrait
Edit/add form of a blog category.
Multilingual fields (name, URL, editor info, meta*); untranslated: parent category (tree) and
the free flag. The nested-set indexes (lft/rgt/level) are maintained by the Api: on a new
category by save() (insertTreeNode), on a parent change by moveSubtree().
The skeleton comes from BasePresenter::createForm().
Table of Contents
Methods
- createComponentEditForm() : Form
- addStructureFields() : void
- Structure: activation, parent category (tree), flags and main image.
- addTranslationFields() : void
- Multilingual fields: one set per language (`<field>_<langId>`), active according to the checkbox.
- buildCategoryEntity() : Category
- collectImageMeta() : array<string, mixed>
- Builds `$meta` for save: a new image (base64) and/or the delete flag.
- isHrefUnique() : bool
- Validates href uniqueness in the given language against other categories (the edited category is not counted when editing). An empty href (nullable) is not checked.
- saveCategoryForm() : bool
- setCategoryFormDefaults() : void
Methods
createComponentEditForm()
protected
createComponentEditForm() : Form
Return values
FormaddStructureFields()
Structure: activation, parent category (tree), flags and main image.
private
addStructureFields(Form $form) : void
Parameters
- $form : Form
addTranslationFields()
Multilingual fields: one set per language (`<field>_<langId>`), active according to the 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
CategorycollectImageMeta()
Builds `$meta` for save: a new image (base64) and/or the delete flag.
private
collectImageMeta(ArrayHash<string|int, mixed> $values) : array<string, mixed>
The Api turns it into an Asset (variants) and sets the FK to the main image.
Parameters
- $values : ArrayHash<string|int, mixed>
Return values
array<string, mixed>isHrefUnique()
Validates href uniqueness in the given language against other categories (the edited category is not counted when editing). An empty href (nullable) is not checked.
private
isHrefUnique(TextInput $input, int $langId) : bool
Parameters
- $input : TextInput
- $langId : int
Return values
boolsaveCategoryForm()
private
saveCategoryForm(ArrayHash<string|int, mixed> $values) : bool
Parameters
- $values : ArrayHash<string|int, mixed>
Return values
boolsetCategoryFormDefaults()
private
setCategoryFormDefaults(Form $form) : void
Parameters
- $form : Form