FormTrait
Requires in the host class: - $this->translator - $this->translatorDomain - $this->watchdogId (int) - $this->watchdogManager (WatchdogManager) - $this->categoryManager (CategoryManager) - $this->categorySuggestFactory (CategorySuggestFactory) - $this->regionManager (RegionManager) - $this->regionSuggestFactory (RegionSuggestFactory) - $this->languageManager (LanguageManager) - $this->parameterManager (ParameterManager) - $this->languageContext - updateModalContent(): void (z ModalTrait) - createSuccessContent(): string (z ModalTrait) - createFormContent(): string (z ModalTrait) - getPresenter() - getPresenterIfExists()
Table of Contents
Constants
- STATE_PARAMETER_KEY : string = 'state'
- Key of the parent parameter "state".
- TYPE_PARAMETER_KEY : string = 'type'
- Key of the parent parameter "type" (options = its children, the advert carries `value` = option id).
Methods
- onError() : void
- Invalid form: the modal must be redrawn, otherwise the user does not see field errors (region from the suggest, e-mail). Errors without a field (CSRF) have no field in the template, so they go to a generic flash.
- onSuccess() : void
- onValidate() : void
- The category is required; typed text without a choice from the suggest is an error.
- createComponentCategorySuggest() : CategorySuggest
- Category suggest (shared component, source = the front `CategoryManager` of the module): a category of any level can be watched; matching with an advert goes through the subtree of the watchdog category.
- createComponentForm() : Form
- createComponentRegionSuggest() : RegionSuggest
- Region suggest: a watchdog may watch a country, region, district or municipality; matching goes through the ancestors of the advert region.
- prepareFormTemplate() : void
- getCategoryLabel() : string
- getParameterLabel() : string
- isSelectableCategory() : bool
- The chosen category exists, is active and is not admin-only (any tree level).
- isSelectableRegion() : bool
- The chosen region exists and is active (any tree level).
- isTyped() : bool
- The user typed something into the suggest field (regardless of a choice from the options).
- prepareLanguageList() : array<int, string>
- prepareStateList() : array<int, string>
- prepareTypeList() : array<int, string>
- resolveCategoryLabel() : string
- Label of the saved category for edit (suggest text); a non-existent one gives an empty text.
- resolveDefaultRegionId() : int|null
- Localization country (`cms_system_localizations.cms_system_regions_region_id`).
- resolveLanguageId() : int
- resolveRegionId() : int
Constants
STATE_PARAMETER_KEY
Key of the parent parameter "state".
private
string
STATE_PARAMETER_KEY
= 'state'
TYPE_PARAMETER_KEY
Key of the parent parameter "type" (options = its children, the advert carries `value` = option id).
private
string
TYPE_PARAMETER_KEY
= 'type'
Methods
onError()
Invalid form: the modal must be redrawn, otherwise the user does not see field errors (region from the suggest, e-mail). Errors without a field (CSRF) have no field in the template, so they go to a generic flash.
public
onError(Form $form) : void
Parameters
- $form : Form
onSuccess()
public
onSuccess(Form $form, ArrayHash $values) : void
Parameters
- $form : Form
- $values : ArrayHash
onValidate()
The category is required; typed text without a choice from the suggest is an error.
public
onValidate(Container $form) : void
Without a region the localization country is watched; when the localization has none, the region is required. Typed text without a choice is an error (otherwise "Brnoo" would store the whole country).
Parameters
- $form : Container
createComponentCategorySuggest()
Category suggest (shared component, source = the front `CategoryManager` of the module): a category of any level can be watched; matching with an advert goes through the subtree of the watchdog category.
protected
createComponentCategorySuggest() : CategorySuggest
Return values
CategorySuggestcreateComponentForm()
protected
createComponentForm() : Form
Return values
FormcreateComponentRegionSuggest()
Region suggest: a watchdog may watch a country, region, district or municipality; matching goes through the ancestors of the advert region.
protected
createComponentRegionSuggest() : RegionSuggest
Return values
RegionSuggestprepareFormTemplate()
protected
prepareFormTemplate() : void
getCategoryLabel()
private
getCategoryLabel(Category $category, int|null $langId) : string
Parameters
- $category : Category
- $langId : int|null
Return values
stringgetParameterLabel()
private
getParameterLabel(Parameter $parameter, int|null $langId) : string
Parameters
- $parameter : Parameter
- $langId : int|null
Return values
stringisSelectableCategory()
The chosen category exists, is active and is not admin-only (any tree level).
private
isSelectableCategory(mixed $value) : bool
Parameters
- $value : mixed
Return values
boolisSelectableRegion()
The chosen region exists and is active (any tree level).
private
isSelectableRegion(mixed $value) : bool
Parameters
- $value : mixed
Return values
boolisTyped()
The user typed something into the suggest field (regardless of a choice from the options).
private
isTyped(TextInput $display) : bool
Parameters
- $display : TextInput
Return values
boolprepareLanguageList()
private
prepareLanguageList() : array<int, string>
Return values
array<int, string>prepareStateList()
private
prepareStateList() : array<int, string>
Return values
array<int, string>prepareTypeList()
private
prepareTypeList() : array<int, string>
Return values
array<int, string>resolveCategoryLabel()
Label of the saved category for edit (suggest text); a non-existent one gives an empty text.
private
resolveCategoryLabel(int $categoryId) : string
Parameters
- $categoryId : int
Return values
stringresolveDefaultRegionId()
Localization country (`cms_system_localizations.cms_system_regions_region_id`).
private
resolveDefaultRegionId() : int|null
Return values
int|nullresolveLanguageId()
private
resolveLanguageId() : int
Return values
intresolveRegionId()
private
resolveRegionId(mixed $value) : int
Parameters
- $value : mixed