CoolCMS API

ServiceFormTrait

Service / price list item add/edit form: company and group (selects), price/rate, visibility and per-language tabs (name, description).

The skeleton (translator, back key, save/apply/cancel buttons) is BasePresenter::createForm(); multilingual fields and safe conversions come from AdminFormHelpersTrait. activated is the global service activation (a toggle in the template header); public is a plain checkbox that controls only visibility in the price list, not availability.

Table of Contents

Methods

createComponentEditForm()  : Form
addBasicFields()  : void
Company, group, price/rate, order, visibility and global activation.
addTranslationFields()  : void
Multilingual fields (name, description) per language, active per checkbox.
buildServiceEntity()  : Service
saveServiceForm()  : bool
Saves the form data. The redirect is handled by {@see \App\Core\Base\Admin\BasePresenter::createForm()}.
setServiceFormDefaults()  : void
tr()  : NotTranslate
Translates a key in the form domain into a ready string (for fields with `setTranslator(null)`).

Methods

addBasicFields()

Company, group, price/rate, order, visibility and global activation.

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

addTranslationFields()

Multilingual fields (name, description) per language, active per checkbox.

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

buildServiceEntity()

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

saveServiceForm()

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

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