CoolCMS API

FlashMessageFormTrait

Edit/add form of a flash message (promo card).

Multilingual fields (title, text, long editor text); untranslated: display dates and activation (toggle in the header), main image and the publishing author.

The main 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 the Asset entity are saved by FlashMessageManager.

The author is chosen via the picker (hidden userId + UserPickerTrait) and written through the user object association: the scalar userId in the parent is a read-only mirror of the same column, so an empty association would override it on the write path. The skeleton comes from BasePresenter::createForm().

Table of Contents

Constants

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

Methods

createComponentEditForm()  : Form
addMainFields()  : void
Untranslated fields: display dates, activation, main image and author (picker).
addTranslationFields()  : void
Multilingual fields: one set per language (`<field>_<langId>`), active according to the checkbox.
buildFlashMessageEntity()  : FlashMessage
collectImageMeta()  : array<string, mixed>
Builds `$meta` for save: a new image (base64) and/or the delete flag.
saveFlashMessageForm()  : bool
setFlashMessageFormDefaults()  : void

Constants

FLASH_DT_FORMAT

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

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

Methods

addMainFields()

Untranslated fields: display dates, activation, main image and author (picker).

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

collectImageMeta()

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>

saveFlashMessageForm()

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

Search results