TYPO3  7.6
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
SelectViewHelper Class Reference
Inheritance diagram for SelectViewHelper:
AbstractFormFieldViewHelper AbstractFormViewHelper AbstractTagBasedViewHelper AbstractViewHelper TranslateLabelSelectViewHelper SelectViewHelper

Public Member Functions

 initializeArguments ()
 
 render ()
 
- Public Member Functions inherited from AbstractFormFieldViewHelper
 initializeArguments ()
 
 getRespectSubmittedDataValue ()
 
 setRespectSubmittedDataValue ($respectSubmittedDataValue)
 

Protected Member Functions

 renderOptionTags ($options)
 
 getOptions ()
 
 isSelected ($value)
 
 getSelectedValue ()
 
 getOptionValueScalar ($valueElement)
 
 renderOptionTag ($value, $label, $isSelected)
 
- Protected Member Functions inherited from AbstractFormFieldViewHelper
 getName ()
 
 getRequest ()
 
 getNameWithoutPrefix ()
 
 getValue ($convertObjects=true)
 
 getValueAttribute ()
 
 getValueFromSubmittedFormData ($value)
 
 convertToPlainValue ($value)
 
 hasMappingErrorOccurred ()
 
 getLastSubmittedFormData ()
 
 addAdditionalIdentityPropertiesIfNeeded ()
 
 getPropertyValue ()
 
 isObjectAccessorMode ()
 
 setErrorClassAttribute ()
 
 getMappingResultsForProperty ()
 
 renderHiddenFieldForEmptyValue ()
 
- Protected Member Functions inherited from AbstractFormViewHelper
 prefixFieldName ($fieldName)
 
 renderHiddenIdentityField ($object, $name)
 
 registerFieldNameForFormTokenGeneration ($fieldName)
 
- Protected Member Functions inherited from AbstractTagBasedViewHelper
 registerTagAttribute ($name, $type, $description, $required=false, $default=null)
 
 registerUniversalTagAttributes ()
 
- Protected Member Functions inherited from AbstractViewHelper
 registerArgument ($name, $type, $description, $required=false, $defaultValue=null)
 
 overrideArgument ($name, $type, $description, $required=false, $defaultValue=null)
 
 callRenderMethod ()
 
 getLogger ()
 
 buildRenderChildrenClosure ()
 
 hasArgument ($argumentName)
 

Protected Attributes

 $tagName = 'select'
 
 $selectedValue = null
 
- Protected Attributes inherited from AbstractFormFieldViewHelper
 $configurationManager
 
 $respectSubmittedDataValue = false
 
- Protected Attributes inherited from AbstractFormViewHelper
 $persistenceManager
 
- Protected Attributes inherited from AbstractTagBasedViewHelper
 $tag = null
 
 $tagName = 'div'
 
- Protected Attributes inherited from AbstractViewHelper
 $arguments
 
 $templateVariableContainer
 
 $controllerContext
 
 $renderingContext
 
 $renderChildrenClosure = null
 
 $viewHelperVariableContainer
 
 $objectManager
 
 $escapingInterceptorEnabled = true
 

Additional Inherited Members

- Static Public Member Functions inherited from AbstractViewHelper
static renderStatic (array $arguments,\Closure $renderChildrenClosure,\TYPO3\CMS\Fluid\Core\Rendering\RenderingContextInterface $renderingContext)
 

Detailed Description

This view helper generates a <select> dropdown list for the use with a form.

= 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 value is used as human-readable name.

<f:form.select name="paymentOptions" options="{payPal: 'PayPal International Services', visa: 'VISA Card'}" />

= Pre-select a value =

To pre-select a value, set "value" to the option key which should be selected. <f:form.select name="paymentOptions" options="{payPal: 'PayPal International Services', visa: 'VISA Card'}" value="visa" /> Generates a dropdown box like above, except that "VISA Card" is 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 (UID/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 provided, the value of the prependOptionValue variable as value.

<f:form.select name="users" options="{userArray}" optionValueField="id" optionLabelField="firstName" /> In the above example, the userArray is an array of "User" domain objects, with no array key specified.

So, in the above example, 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.

Definition at line 58 of file fluid/Classes/ViewHelpers/Form/SelectViewHelper.php.

Member Function Documentation

getOptions ( )
protected

Render the option tags.

Returns
array an associative array of options, key will be the value of the option tag

Definition at line 155 of file fluid/Classes/ViewHelpers/Form/SelectViewHelper.php.

References elseif, and AbstractViewHelper\hasArgument().

Referenced by SelectViewHelper\render().

getOptionValueScalar (   $valueElement)
protected

Get the option value for an object

Parameters
mixed$valueElement
Returns
string

Definition at line 252 of file fluid/Classes/ViewHelpers/Form/SelectViewHelper.php.

References AbstractViewHelper\hasArgument().

Referenced by SelectViewHelper\getSelectedValue().

getSelectedValue ( )
protected
initializeArguments ( )
isSelected (   $value)
protected

Render the option tags.

Parameters
mixed$valueValue to check for
Returns
bool TRUE if the value should be marked a s selected; FALSE otherwise

Definition at line 211 of file fluid/Classes/ViewHelpers/Form/SelectViewHelper.php.

References SelectViewHelper\$selectedValue, elseif, SelectViewHelper\getSelectedValue(), and AbstractViewHelper\hasArgument().

Referenced by SelectViewHelper\renderOptionTags().

render ( )
renderOptionTag (   $value,
  $label,
  $isSelected 
)
protected

Render one option tag

Parameters
string$valuevalue attribute of the option tag (will be escaped)
string$labelcontent of the option tag (will be escaped)
bool$isSelectedspecifies wheter or not to add selected attribute
Returns
string the rendered option tag

Definition at line 278 of file fluid/Classes/ViewHelpers/Form/SelectViewHelper.php.

Referenced by SelectViewHelper\renderOptionTags().

renderOptionTags (   $options)
protected

Render the option tags.

Parameters
array$optionsthe options for the form.
Returns
string rendered tags.

Definition at line 135 of file fluid/Classes/ViewHelpers/Form/SelectViewHelper.php.

References AbstractViewHelper\hasArgument(), SelectViewHelper\isSelected(), and SelectViewHelper\renderOptionTag().

Referenced by SelectViewHelper\render().

Member Data Documentation

$selectedValue = null
protected
$tagName = 'select'
protected