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
파일 보기 프로젝트 열기: neos/flow-development-collection 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$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