DependentSelectTrait
Converts a select whose options are targets of rules with {@see \App\Core\Base\Shared\Bazaar\Models\Entities\ParameterRule::ACTION_SHOW_SELECT_OPTIONS} to a {@see DependentSelectBox}.
Items are loaded via AJAX after the parent changes (signal dependentSelectBoxLoad on the
hosting UI control). On the initial render the items are filled from the parent values of the
entity (edit mode) or from parameter defaults (insert mode).
Table of Contents
Methods
- areAllConditionsMet() : bool
- buildDependentData() : DependentData
- collectOptionLabels() : array<int, string>
- collectRuleControlledOptionIds() : array<int, true>
- collectShowSelectOptionsRules() : array<string|int, ParameterRuleInterface>
- collectSourceKeys() : array<string|int, string>
- extractParameterIdFromKey() : int|null
- initializeFormElementDependencies() : void
- isConditionMet() : bool
- replaceWithDependentSelect() : void
- resolveInitialParentValues() : array<string, mixed>
- resolveOptionLabel() : string
Methods
areAllConditionsMet()
private
areAllConditionsMet(ParameterRuleInterface $rule, array<string, mixed> $parentValues) : bool
Parameters
- $rule : ParameterRuleInterface
- $parentValues : array<string, mixed>
Return values
boolbuildDependentData()
private
buildDependentData(ParameterInterface $parameter, array<string|int, ParameterRuleInterface> $rules, array<string, mixed> $parentValues, string|null $prompt) : DependentData
Parameters
- $parameter : ParameterInterface
- $rules : array<string|int, ParameterRuleInterface>
- $parentValues : array<string, mixed>
- $prompt : string|null
Return values
DependentDatacollectOptionLabels()
private
collectOptionLabels(ParameterInterface $parameter) : array<int, string>
Parameters
- $parameter : ParameterInterface
Return values
array<int, string>collectRuleControlledOptionIds()
private
collectRuleControlledOptionIds(array<string|int, ParameterRuleInterface> $rules) : array<int, true>
Parameters
- $rules : array<string|int, ParameterRuleInterface>
Return values
array<int, true>collectShowSelectOptionsRules()
private
collectShowSelectOptionsRules(ParameterInterface $parameter) : array<string|int, ParameterRuleInterface>
Parameters
- $parameter : ParameterInterface
Return values
array<string|int, ParameterRuleInterface>collectSourceKeys()
private
collectSourceKeys(Form $form, array<string|int, ParameterRuleInterface> $rules) : array<string|int, string>
Parameters
- $form : Form
- $rules : array<string|int, ParameterRuleInterface>
Return values
array<string|int, string> —form component keys (e.g. parameter_42)
extractParameterIdFromKey()
private
extractParameterIdFromKey(string $controlKey) : int|null
Parameters
- $controlKey : string
Return values
int|nullinitializeFormElementDependencies()
private
initializeFormElementDependencies(Form $form) : void
Parameters
- $form : Form
isConditionMet()
private
isConditionMet(ParameterRuleConditionInterface $condition, array<string, mixed> $parentValues) : bool
Parameters
- $condition : ParameterRuleConditionInterface
- $parentValues : array<string, mixed>
Return values
boolreplaceWithDependentSelect()
private
replaceWithDependentSelect(Form $form, ParameterInterface $parameter, string $key, array<string|int, ParameterRuleInterface> $rules, array<string|int, string> $sourceKeys, array<int, mixed> $entityValues) : void
Parameters
- $form : Form
- $parameter : ParameterInterface
- $key : string
- $rules : array<string|int, ParameterRuleInterface>
- $sourceKeys : array<string|int, string>
- $entityValues : array<int, mixed>
resolveInitialParentValues()
private
resolveInitialParentValues(Form $form, array<string|int, string> $sourceKeys, array<int, mixed> $entityValues) : array<string, mixed>
Parameters
- $form : Form
- $sourceKeys : array<string|int, string>
- $entityValues : array<int, mixed>
Return values
array<string, mixed>resolveOptionLabel()
private
resolveOptionLabel(ParameterInterface $option) : string
Parameters
- $option : ParameterInterface