CoolCMS API

CalendarFormTrait

Calendar add/edit form: company (select), name, color, order, opening hours (7 days x 2 windows), offer step, lead time, flags and per-language tabs.

The language tabs carry front_name/description per language (CalendarText, same pattern as ServiceFormTrait::addTranslationFields()); Calendar::name stays internal and has no language tabs, unlike the presentational front_name.

Table of Contents

Methods

createComponentEditForm()  : Form
addBasicFields()  : void
addOpeningHoursFields()  : void
Same fields as `CompanyFormTrait::addOpeningHoursFields()`.
addTranslationFields()  : void
Adds the visitor-facing multilingual fields: presentation name and description per language.
buildCalendarEntity()  : Calendar
buildOpeningHours()  : array<int, array<int, array{0: string, 1: string}>>|null
Builds `[dow => [[from,to],…]]` from the filled pairs only and normalizes it via {@see OpeningHours}. An empty result returns null (no opening hours).
saveCalendarForm()  : bool
Saves the form data. The redirect is handled by {@see \App\Core\Base\Admin\BasePresenter::createForm()}.
setCalendarFormDefaults()  : void
tr()  : NotTranslate
Translates a key in the form domain into a ready string (for fields with `setTranslator(null)`).

Methods

addOpeningHoursFields()

Same fields as `CompanyFormTrait::addOpeningHoursFields()`.

private addOpeningHoursFields(Form $form) : void
Parameters
$form : Form

addTranslationFields()

Adds the visitor-facing multilingual fields: presentation name and description per language.

private addTranslationFields(Form $form) : void

IMPORTANT: the active_<lang> checkbox is required for every language. The shared LangNav template renders it, and without it adminLangNav fails with Nette\InvalidArgumentException: Component with name 'active_<lid>' does not exist. It marks whether that language variant is active (CalendarText::activeTranslation), not the visibility of the calendar as a whole (that is public/active on the record).

Parameters
$form : Form

buildCalendarEntity()

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

buildOpeningHours()

Builds `[dow => [[from,to],…]]` from the filled pairs only and normalizes it via {@see OpeningHours}. An empty result returns null (no opening hours).

private buildOpeningHours(ArrayHash<string|int, mixed> $values) : array<int, array<int, array{0: string, 1: string}>>|null

Same logic as CompanyFormTrait::buildOpeningHours().

Parameters
$values : ArrayHash<string|int, mixed>
Return values
array<int, array<int, array{0: string, 1: string}>>|null

saveCalendarForm()

Saves the form data. The redirect is handled by {@see \App\Core\Base\Admin\BasePresenter::createForm()}.

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

tr()

Translates a key in the form domain into a ready string (for fields with `setTranslator(null)`).

private tr(string $key) : NotTranslate

IMPORTANT: the result goes to setPrompt()/setRequired() on a field with setTranslator(null). Prompt and items respect the control override, but Nette getLabel() and Validator::formatMessage() always take the translator from the form; without NotTranslate the finished text would be translated again as a key and Tracy would report a missing translation.

Parameters
$key : string
Return values
NotTranslate
On this page

Search results