Trait Options
Trait 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
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
boolean
|
#
GetTranslateOptions( )
Return boolean if options are translated or not.
Return boolean if options are translated or not.
Returns
boolean
|
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
|
Properties summary
protected
array
|
$options
Form group control options to render
more sub-control attributes for specified
submitted values (array keys).
This property configuration is required.
Form group control options to render
more sub-control attributes for specified
submitted values (array keys).
This property configuration is required.
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->name = 'gender';
$field->options = array( '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->name = 'gender';
$field->options = 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'), ),
));
Requires
|
|
protected
array|null
|
$flattenOptions
Temp flatten key/value array to cache flatten options for submit checking.
Temp flatten key/value array to cache flatten options for submit checking.
|
|
protected
boolean
|
$translateOptions
Boolean about to translate options texts, default TRUE to translate.
Boolean about to translate options texts, default TRUE to translate.
|
|