ServiceGroupFormTrait
Price list group add/edit form: company (select), order, price list visibility, photo and per-language tabs (name).
The skeleton (translator, back key, save/apply/cancel buttons) is
BasePresenter::createForm(); multilingual fields and safe
conversions come from AdminFormHelpersTrait.
companyId is a select, not a Picker: the number of companies is small in practice.
The group photo is one image via Form::addImageUpload() (same as
ReferenceFormTrait::logo): the bytes go to $meta['image'] and
ServiceGroupManager creates the Asset variants.
Table of Contents
Methods
- createComponentEditForm() : Form
- addBasicFields() : void
- Company, order in the price list and front-end visibility.
- addTranslationFields() : void
- Multilingual fields (group name) per language (`name_<langId>`), active per checkbox.
- buildServiceGroupEntity() : ServiceGroup
- collectImageMeta() : array<string, mixed>
- Builds `$meta` for the group photo: a new image (base64) and/or the delete flag.
- saveServiceGroupForm() : bool
- Saves the form data. The redirect is handled by {@see \App\Core\Base\Admin\BasePresenter::createForm()}.
- setServiceGroupFormDefaults() : void
- tr() : NotTranslate
- Translates a key in the form domain into a ready string (for fields with `setTranslator(null)`).
Methods
createComponentEditForm()
protected
createComponentEditForm() : Form
Return values
FormaddBasicFields()
Company, order in the price list and front-end visibility.
private
addBasicFields(Form $form) : void
Parameters
- $form : Form
addTranslationFields()
Multilingual fields (group name) per language (`name_<langId>`), active per checkbox.
private
addTranslationFields(Form $form) : void
Parameters
- $form : Form
buildServiceGroupEntity()
private
buildServiceGroupEntity(ArrayHash<string|int, mixed> $values) : ServiceGroup
Parameters
- $values : ArrayHash<string|int, mixed>
Return values
ServiceGroupcollectImageMeta()
Builds `$meta` for the group photo: a new image (base64) and/or the delete flag.
private
collectImageMeta(ArrayHash<string|int, mixed> $values) : array<string, mixed>
The Api creates the Asset (variants) and sets the FK imageId.
Parameters
- $values : ArrayHash<string|int, mixed>
Return values
array<string, mixed>saveServiceGroupForm()
Saves the form data. The redirect is handled by {@see \App\Core\Base\Admin\BasePresenter::createForm()}.
private
saveServiceGroupForm(ArrayHash<string|int, mixed> $values) : bool
Parameters
- $values : ArrayHash<string|int, mixed>
Return values
boolsetServiceGroupFormDefaults()
private
setServiceGroupFormDefaults(Form $form) : void
Parameters
- $form : Form
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