Responsibility: init, pre-dispatch and render common form control, it could be input
, select
or textarea. This class is not possible to instantiate, you need to extend this class to create own specific form control.
Methods summary
public static
MvcCore\Ext\Forms\Field
|
#
CreateInstance( array $cfg = [] )
Create new form control instance.
Create new form control instance.
Parameters
- $cfg
Config array with public properties and it's
values which you want to configure, presented
in camel case properties names syntax.
Returns
Throws
InvalidArgumentException
Implementation of
|
public
|
#
__construct( array $cfg = [] )
Create new form control instance.
Create new form control instance.
Parameters
- $cfg
Config array with public properties and it's
values which you want to configure, presented
in camel case properties names syntax.
Throws
InvalidArgumentException
|
public
mixed|MvcCore\Ext\Forms\Field
|
#
__call( string $name, array $arguments = [] )
Sets any custom property "propertyName" by \MvcCore\Ext\Forms\Field::SetPropertyName("value"); ,
which is not necessary to define previously or gets previously defined
property "propertyName" by \MvcCore\Ext\Forms\Field::GetPropertyName(); .
Throws exception if no property defined by get call or if virtual call
begins with anything different from Set or Get .
This method returns custom value for get and \MvcCore\Request instance for set.
Sets any custom property "propertyName" by \MvcCore\Ext\Forms\Field::SetPropertyName("value"); ,
which is not necessary to define previously or gets previously defined
property "propertyName" by \MvcCore\Ext\Forms\Field::GetPropertyName(); .
Throws exception if no property defined by get call or if virtual call
begins with anything different from Set or Get .
This method returns custom value for get and \MvcCore\Request instance for set.
Parameters
Returns
Throws
InvalidArgumentException
|
public
mixed
|
#
__get( string $name )
Universal getter, if property not defined - NULL is returned.
Universal getter, if property not defined - NULL is returned.
Parameters
Returns
mixed
|
public
MvcCore\Ext\Forms\Field
|
#
__set( string $name, mixed $value )
Universal setter, if property not defined - it's automatically declared.
Universal setter, if property not defined - it's automatically declared.
Parameters
Returns
|
public
MvcCore\Ext\Forms\Field
|
#
SetForm( MvcCore\Ext\IForm $form )
This INTERNAL method is called from \MvcCore\Ext\Form after field
is added into form instance by $form->AddField(); method. Do not
use this method even if you don't develop any form field.
- Check if field has any name, which is required.
- Set up form and field id attribute by form id and field name.
- Set up required.
- Set up translate boolean property.
This INTERNAL method is called from \MvcCore\Ext\Form after field
is added into form instance by $form->AddField(); method. Do not
use this method even if you don't develop any form field.
- Check if field has any name, which is required.
- Set up form and field id attribute by form id and field name.
- Set up required.
- Set up translate boolean property.
Parameters
Returns
Throws
InvalidArgumentException
Implementation of
|
public
|
#
PreDispatch( )
This INTERNAL method is called from \MvcCore\Ext\Form just before
field is naturally rendered. It sets up field for rendering process.
Do not use this method even if you don't develop any form field.
- Set up field render mode if not defined.
- Translate label text if necessary.
This INTERNAL method is called from \MvcCore\Ext\Form just before
field is naturally rendered. It sets up field for rendering process.
Do not use this method even if you don't develop any form field.
- Set up field render mode if not defined.
- Translate label text if necessary.
Implementation of
|
public
string|integer|array|null
|
#
Submit( array & $rawRequestParams = [] )
This INTERNAL method is called from \MvcCore\Ext\Form
in submit processing. Do not use this method even if you
don't develop form library or any form field.
This INTERNAL method is called from \MvcCore\Ext\Form
in submit processing. Do not use this method even if you
don't develop form library or any form field.
Submit field value - process raw request value with all
configured validators and add errors into form if necessary.
Then return safe processed value by all from validators or NULL .
Parameters
- $rawRequestParams
Raw request params from MvcCore
request object based on raw app
input, $_GET or $_POST .
Returns
string|integer|array|null
Implementation of
|
public
array
&
|
#
GetValidatorData( array $fieldPropsDefaultValidValues = [] )
Default implementation for any extended field class to get field specific
data for validator purposes. If you want to extend any field, you could
implement this method better and faster. It's only necessary in your
implementation to return array with keys to be field specific properties
in camel case and values to be field properties values, which validator
requires.
Default implementation for any extended field class to get field specific
data for validator purposes. If you want to extend any field, you could
implement this method better and faster. It's only necessary in your
implementation to return array with keys to be field specific properties
in camel case and values to be field properties values, which validator
requires.
Parameters
- $fieldPropsDefaultValidValues
Returns
array
Implementation of
|
public
MvcCore\Ext\Forms\Field
|
#
AddValidationError( string $errorMsg = '', array $errorMsgArgs = [], callable $replacingCallable = NULL )
This INTERNAL method is called from \MvcCore\Ext\Forms\Field
in submit processing. Do not use this method even if you
don't develop any form field or field validator.
This INTERNAL method is called from \MvcCore\Ext\Forms\Field
in submit processing. Do not use this method even if you
don't develop any form field or field validator.
Add form error with given error message containing
possible replacements for array values.
If there is necessary to translate form elements
(form has configured property translator as callable )
than given error message is translated first before replacing.
Before error message processing for replacements,
there is automatically assigned into first position into $errorMsgArgs
array (translated) field label or field name and than
error message is processed for replacements.
If there is given some custom $replacingCallable param,
error message is processed for replacements by custom $replacingCallable .
If there is not given any custom $replacingCallable param,
error message is processed for replacements by static Format()
method by configured form view class.
Parameters
- $errorMsg
- $errorMsgArgs
- $replacingCallable
Returns
Implementation of
|
protected
string
|
#
translateAndFormatValidationError( string $errorMsg = '', array $errorMsgArgs = [], callable $replacingCallable = NULL )
Format form error with given error message containing
possible replacements for array values.
Format form error with given error message containing
possible replacements for array values.
If there is necessary to translate form elements
(form has configured property translator as callable )
than given error message is translated first before replacing.
Before error message processing for replacements,
there is automatically assigned into first position into $errorMsgArgs
array (translated) field label or field name and than
error message is processed for replacements.
If there is given some custom $replacingCallable param,
error message is processed for replacements by custom $replacingCallable .
If there is not given any custom $replacingCallable param,
error message is processed for replacements by static Format()
method by configured form view class.
Parameters
- $errorMsg
- $errorMsgArgs
- $replacingCallable
Returns
string
|
protected
|
#
throwNewInvalidArgumentException( string $errorMsg )
Throw new \InvalidArgumentException with given
error message and append automatically current class name,
current form id, form class type and current field class type.
Throw new \InvalidArgumentException with given
error message and append automatically current class name,
current form id, form class type and current field class type.
Parameters
Throws
InvalidArgumentException
|