PollPickerTrait
Poll picker — the reusable "many objects pick Poll" pattern (e.g. a poll place picks polls).
A presenter uses this trait + PickerHostTrait, returns pollPicker() from
pickers() and creates the fields in a multiplier row through addPollControls().
Poll label = question (translations.question) in the current language. Requires
$this->pollManager in the presenter.
Table of Contents
Methods
- addPollControls() : void
- pollPicker() : PickerConfig
- pollQuestion() : string
- Poll question in the current language (falls back to the first non-empty one).
- resolvePollLabel() : string|null
- Label (question) for prefilling on edit (from the hidden value).
- suggestPolls() : array<int, array{id: int, label: string}>
Methods
addPollControls()
protected
addPollControls(Container $parent[, string $targetField = 'pollId' ][, string $displayField = 'poll' ]) : void
Parameters
- $parent : Container
- $targetField : string = 'pollId'
- $displayField : string = 'poll'
pollPicker()
protected
pollPicker([string $formName = 'editForm' ][, string|null $container = 'polls' ][, string $targetField = 'pollId' ][, string $displayField = 'poll' ]) : PickerConfig
Parameters
- $formName : string = 'editForm'
- $container : string|null = 'polls'
- $targetField : string = 'pollId'
- $displayField : string = 'poll'
Return values
PickerConfigpollQuestion()
Poll question in the current language (falls back to the first non-empty one).
private
pollQuestion(Poll $poll) : string
Parameters
- $poll : Poll
Return values
stringresolvePollLabel()
Label (question) for prefilling on edit (from the hidden value).
private
resolvePollLabel(int $id) : string|null
Parameters
- $id : int
Return values
string|nullsuggestPolls()
private
suggestPolls(string $query) : array<int, array{id: int, label: string}>
Parameters
- $query : string