Interface IOptions
Responsibility: define getters and setters for field property options
.
Interface for classes:
- \MvcCore\Ext\Forms\Fields\DataList
- \MvcCore\Ext\Forms\Fields\Select
- \MvcCore\Ext\Forms\Fields\CountrySelect
- \MvcCore\Ext\Forms\FieldsGroup
- \MvcCore\Ext\Forms\CheckboxGroup
- \MvcCore\Ext\Forms\RadioGroup
- \MvcCore\Ext\Forms\Validators\ValueInOptions
Methods summary
public
MvcCore\Ext\Forms\Field
|
#
SetOptions( array $options = [] )
Set form control or group control options to render
more values for more specified submitted keys.
Set form control or group control options to render
more values for more specified submitted keys.
Example:
// To configure for example radio buttons named: `gender` for `Female` and `Male`:
// <label for="gender-f">Female:</label>
// <input id="gender-f" type="radio" name="gender" value="f" />
// <label for="gender-m">Male:</label>
// <input id="gender-m" type="radio" name="gender" value="m" />
// use this configuration:
$field->SetName('gender')->SetOptions(array( // field values will be automatically translated, // if form has configured translator `callable` 'f' => 'Female', 'm' => 'Male',
));
// Or you can use more advanced configuration with css class names
// and html element attributes, let's consider html code like this:
// <label for="gender-f" class="female">Female:</label>
// <input id="gender-f" type="radio" name="gender" value="f" class="female" data-any="something-for-females" />
// <label for="gender-m" class="male">Male:</label>
// <input id="gender-m" type="radio" name="gender" value="m" class="male" data-any="something-for-males" />
// For that use this configuration:
$field->SetName('gender')->SetOptions(array( 'f' => array( 'text' => 'Female', // text key will be also automatically translated 'class' => 'female', 'attrs' => array('data-any' => 'something-for-females'), ), 'm' => array( 'text' => 'Male', // text key will be also automatically translated 'class' => 'male', 'attrs' => array('data-any' => 'something-for-males'), ),
));
Parameters
Returns
|
public
MvcCore\Ext\Forms\Field
|
#
AddOptions( array $options = [] )
Add form control or group control options to render
more values for more specified submitted keys.
Previous options will be merged with given options.
Add form control or group control options to render
more values for more specified submitted keys.
Previous options will be merged with given options.
Parameters
Returns
|
public
array
&
|
#
GetOptions( )
Return reference to configured options array.
Return reference to configured options array.
Returns
array
|
public
MvcCore\Ext\Forms\Field
|
#
SetTranslateOptions( boolean $translateOptions = TRUE )
Set FALSE if you don't want to translate options texts, default TRUE .
Set FALSE if you don't want to translate options texts, default TRUE .
Parameters
Returns
|
public
array
|
#
GetTranslateOptions( )
Return boolean if options are translated or not.
Return boolean if options are translated or not.
Returns
array
|
public
array
&
|
#
GetFlattenOptions( array $fieldOptions = NULL )
Merge given field options with possible grouped options into single
level flatten array for submit checking purposes.
Merge given field options with possible grouped options into single
level flatten array for submit checking purposes.
Parameters
Returns
array
|