PHP Класс Neos\FluidAdaptor\ViewHelpers\Form\SelectViewHelper

**Basic usage** The most straightforward way is to supply an associative array as the "options" parameter. The array key is used as option key, and the array value is used as human-readable name. To pre-select a value, set "value" to the option key which should be selected. If the select box is a multi-select box (multiple="true"), then "value" can be an array as well. **Usage on domain objects** If you want to output domain objects, you can just pass them as array into the "options" parameter. To define what domain object value should be used as option key, use the "optionValueField" variable. Same goes for optionLabelField. If neither is given, the Identifier (UUID/uid) and the __toString() method are tried as fallbacks. If the optionValueField variable is set, the getter named after that value is used to retrieve the option key. If the optionLabelField variable is set, the getter named after that value is used to retrieve the option value. If the prependOptionLabel variable is set, an option item is added in first position, bearing an empty string or - if specified - the value of the prependOptionValue variable as value. In the example below, the userArray is an array of "User" domain objects, with no array key specified. Thus the method $user->getId() is called to retrieve the key, and $user->getFirstName() to retrieve the displayed value of each entry. The "value" property now expects a domain object, and tests for object equivalence. **Translation of select content** The ViewHelper can be given a "translate" argument with configuration on how to translate option labels. The array can have the following keys: - "by" defines if translation by message id or original label is to be used ("id" or "label") - "using" defines if the option tag's "value" or "label" should be used as translation input, defaults to "value" - "locale" defines the locale identifier to use, optional, defaults to current locale - "source" defines the translation source name, optional, defaults to "Main" - "package" defines the package key of the translation source, optional, defaults to current package - "prefix" defines a prefix to use for the message id – only works in combination with "by id" = Examples = (Generates a dropdown box like above, except that "VISA Card" is selected.) (Generates a dropdown box, using ids and first names of the User instances.) (depending on variable "salutations") (Generates a dropdown box and uses the values "payPal" and "visa" to look up translations for those ids in the current package's "Main" XLIFF file.) (Generates a dropdown box and uses the values "shop.paymentOptions.payPal" and "shop.paymentOptions.visa" to look up translations for those ids in the current package's "Main" XLIFF file.)
Наследование: extends AbstractFormFieldViewHelper
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$selectedValue mixed
$tagName string
$translator Neos\Flow\I18n\Translator

Открытые методы

Метод Описание
initializeArguments ( ) : void Initialize arguments.
render ( ) : string Render the tag.

Защищенные методы

Метод Описание
getOptionValueScalar ( mixed $valueElement ) : string Get the option value for an object
getOptions ( ) : array Render the option tags.
getSelectedValue ( ) : mixed Retrieves the selected value(s)
getTranslatedLabel ( string $value, string $label ) : string Returns a translated version of the given label
isSelected ( mixed $value ) : boolean Render the option tags.
renderOptionTag ( string $value, string $label ) : string Render one option tag
renderOptionTags ( array $options ) : string Render the option tags.

Описание методов

getOptionValueScalar() защищенный Метод

Get the option value for an object
protected getOptionValueScalar ( mixed $valueElement ) : string
$valueElement mixed
Результат string

getOptions() защищенный Метод

Render the option tags.
protected getOptions ( ) : array
Результат array an associative array of options, key will be the value of the option tag

getSelectedValue() защищенный Метод

Retrieves the selected value(s)
protected getSelectedValue ( ) : mixed
Результат mixed value string or an array of strings

getTranslatedLabel() защищенный Метод

Returns a translated version of the given label
protected getTranslatedLabel ( string $value, string $label ) : string
$value string option tag value
$label string option tag label
Результат string

initializeArguments() публичный Метод

Initialize arguments.
public initializeArguments ( ) : void
Результат void

isSelected() защищенный Метод

Render the option tags.
protected isSelected ( mixed $value ) : boolean
$value mixed Value to check for
Результат boolean TRUE if the value should be marked a s selected; FALSE otherwise

render() публичный Метод

Render the tag.
public render ( ) : string
Результат string rendered tag.

renderOptionTag() защищенный Метод

Render one option tag
protected renderOptionTag ( string $value, string $label ) : string
$value string value attribute of the option tag (will be escaped)
$label string content of the option tag (will be escaped)
Результат string the rendered option tag

renderOptionTags() защищенный Метод

Render the option tags.
protected renderOptionTags ( array $options ) : string
$options array the options for the form.
Результат string rendered tags.

Описание свойств

$selectedValue защищенное свойство

protected mixed $selectedValue
Результат mixed

$tagName защищенное свойство

protected string $tagName
Результат string

$translator защищенное свойство

protected Translator,Neos\Flow\I18n $translator
Результат Neos\Flow\I18n\Translator