CoolCMS API

CarouselFormTrait

Edit/add form of a carousel.

Edits the translated title (tabs), publishing and activation, and the slides (items): a nested multiplier where each row is a per-language HTML code (editor) plus a hidden itemId. Slides are saved through a three-level cascade Carousel to CarouselItem to CarouselItemText (owned collections; the hydrator builds the managed graph). The skeleton comes from BasePresenter::createForm().

Table of Contents

Constants

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

Methods

createComponentEditForm()  : Form
addItemMultiplier()  : void
Slide multiplier. Each row has a hidden `itemId` (a saved row means update) and a multilingual HTML code `code_<langId>` (textarea with `data-editor`; the admin JS turns it into a trimmed TinyMCE, and the instance method `Form::addEditor()` cannot be called in a plain `Container`, so it is replicated). The code is required only for an active language. The create/remove buttons have the `ajax` class so naja redraws the `items` snippet.
buildCarouselEntity()  : Carousel
buildCarouselItems()  : ArrayCollection<int, CarouselItem>
Builds the slides (`CarouselItem` + multilingual `CarouselItemText`) from the multiplier rows.
saveCarouselForm()  : bool
setCarouselFormDefaults()  : void

Constants

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

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

Methods

addItemMultiplier()

Slide multiplier. Each row has a hidden `itemId` (a saved row means update) and a multilingual HTML code `code_<langId>` (textarea with `data-editor`; the admin JS turns it into a trimmed TinyMCE, and the instance method `Form::addEditor()` cannot be called in a plain `Container`, so it is replicated). The code is required only for an active language. The create/remove buttons have the `ajax` class so naja redraws the `items` snippet.

private addItemMultiplier(Form $form, array<int, Checkbox> $activeControls) : void
Parameters
$form : Form
$activeControls : array<int, Checkbox>

activation checkbox per language (gates the required rule)

buildCarouselEntity()

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

buildCarouselItems()

Builds the slides (`CarouselItem` + multilingual `CarouselItemText`) from the multiplier rows.

private buildCarouselItems(ArrayHash<string|int, mixed> $values, Carousel $carousel, array<int, bool> $activeByLang) : ArrayCollection<int, CarouselItem>

Order = row sequence in the submit. Empty rows (no code in any language) are skipped. The hydrator fills carousel (owner) from the cascade.

Parameters
$values : ArrayHash<string|int, mixed>
$carousel : Carousel
$activeByLang : array<int, bool>
Return values
ArrayCollection<int, CarouselItem>

saveCarouselForm()

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

Search results