CoolCMS API

IntroFormTrait

Edit/add form of an intro panel.

Multilingual fields (title, editor text, link, panel image); untranslated: activation (toggle in the header) and publish date. The per-language image is uploaded via the reusable component ImageUpload (field Form::addImageUpload()); the bytes go to the Api in the $meta of the save payload and variants plus relations are saved by IntroManager. The skeleton comes from BasePresenter::createForm().

Table of Contents

Constants

INTRO_DT_FORMAT  : mixed = 'Y-m-d\TH:i'
Value format of `<input type=datetime-local>`.

Methods

createComponentEditForm()  : Form
addMainFields()  : void
Untranslated fields: activation and publish date.
addTranslationFields()  : void
Multilingual fields: one set per language (`<field>_<langId>`), active according to the checkbox.
buildIntroEntity()  : Intro
collectImageMeta()  : array<string, mixed>
Builds `$meta` for save: per language a new image (base64), a delete flag, or the id of the kept image. `imageLanguages` carries all form languages so the Api knows which relations to overwrite (complete state). The Api turns it into an `Asset` (variants) and relations.
editedImageAssetIds()  : array<int, int>
Map `langId => assetId` of the panel's existing images (from the loaded `assetRels`).
saveIntroForm()  : bool
setIntroFormDefaults()  : void

Constants

INTRO_DT_FORMAT

Value format of `<input type=datetime-local>`.

private mixed INTRO_DT_FORMAT = 'Y-m-d\TH:i'

Methods

addMainFields()

Untranslated fields: activation and publish date.

private addMainFields(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

buildIntroEntity()

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

collectImageMeta()

Builds `$meta` for save: per language a new image (base64), a delete flag, or the id of the kept image. `imageLanguages` carries all form languages so the Api knows which relations to overwrite (complete state). The Api turns it into an `Asset` (variants) and relations.

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

editedImageAssetIds()

Map `langId => assetId` of the panel's existing images (from the loaded `assetRels`).

private editedImageAssetIds(Intro $intro) : array<int, int>
Parameters
$intro : Intro
Return values
array<int, int>

saveIntroForm()

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

Search results