Trait AddMethods
Trait for class MvcCore\Ext\Form
containing adding methods for configurable
properties except methods manipulating with form field instances, for those
methods, there is another trait \MvcCore\Ext\Form\FieldMethods
.
Methods summary
public
MvcCore\Ext\Form
|
#
AddAcceptCharset( string $charset )
Add into list of character encodings that the server accepts. The
browser uses them in the order in which they are listed. The default
value,the reserved string 'UNKNOWN' , indicates the same encoding
as that of the document containing the form element.
Add into list of character encodings that the server accepts. The
browser uses them in the order in which they are listed. The default
value,the reserved string 'UNKNOWN' , indicates the same encoding
as that of the document containing the form element.
Parameters
Returns
|
public
MvcCore\Ext\Form
|
#
AddCssClasses( string|string[] $cssClasses )
Add css classes strings for HTML element attribute class .
Given css classes will be added after previously defined css classes.
Default value is an empty array to not render HTML class attribute.
You can define css classes as single string, more classes separated
by space or you can define css classes as array with strings.
Add css classes strings for HTML element attribute class .
Given css classes will be added after previously defined css classes.
Default value is an empty array to not render HTML class attribute.
You can define css classes as single string, more classes separated
by space or you can define css classes as array with strings.
Parameters
Returns
|
public
MvcCore\Ext\Form
|
#
AddError( string $errorMsg, string|array|null $fieldNames = NULL )
Add form submit error and switch form result to zero - to error state.
Add form submit error and switch form result to zero - to error state.
Parameters
- $errorMsg
- Any error message, translated if necessary. All html tags from error message will be removed automatically.
- $fieldNames
- Optional, field name string or array with field names where error happened.
Returns
|
public
MvcCore\Ext\Form
|
#
AddJsSupportFile( string $jsRelativePath = '/fields/custom-type.js', string $jsClassName = 'MvcCoreForm.FieldType', array $constructorParams = [] )
Add supporting javascript file.
Add supporting javascript file.
Parameters
- $jsRelativePath
- Supporting javascript file relative path from protected
\MvcCore\Ext\Form::$jsAssetsRootDir .
- $jsClassName
- Supporting javascript full class name inside supporting file.
- $constructorParams
- Supporting javascript constructor params.
Returns
|
public
MvcCore\Ext\Form
|
#
AddCssSupportFile( string $cssRelativePath = '/fields/custom-type.css' )
Add supporting css file.
Parameters
- $cssRelativePath
- Supporting css file relative path from protected
\MvcCore\Ext\Form::$cssAssetsRootDir .
Returns
|
public static
integer
|
#
AddCsrfErrorHandler( callable $handler, integer|null $priorityIndex = NULL )
Add CSRF (Cross Site Request Forgery) error handler.
If CSRF submit comparison fails, it's automatically processed
queue with this handlers, you can put here for example handler
to de-authenticate your user or anything else to more secure your application.
Params in callable should be two with following types:
- \MvcCore\Ext\Form - Form instance where error happened.
- \MvcCore\Request - Current request object.
- \MvcCore\Response - Current response object.
- string - Translated error message string.
Example:
\MvcCore\Ext\Form::AddCsrfErrorHandler(function($form, $request, $response, $errorMsg) {
// ... anything you want to do, for example to sign out user.
});
Add CSRF (Cross Site Request Forgery) error handler.
If CSRF submit comparison fails, it's automatically processed
queue with this handlers, you can put here for example handler
to de-authenticate your user or anything else to more secure your application.
Params in callable should be two with following types:
- \MvcCore\Ext\Form - Form instance where error happened.
- \MvcCore\Request - Current request object.
- \MvcCore\Response - Current response object.
- string - Translated error message string.
Example:
\MvcCore\Ext\Form::AddCsrfErrorHandler(function($form, $request, $response, $errorMsg) { // ... anything you want to do, for example to sign out user.
});
Parameters
Returns
integer New CSRF error handlers count.
|
public static
integer
|
#
AddValidatorsNamespaces( string[] $validatorsNamespaces )
Add form validators base namespaces to create validator instance by it's class name.
Validator will be created by class existence in this namespaces order.
Validators namespaces array configured by default: array('\\MvcCore\\Ext\\Forms\\Validators\\'); .
Add form validators base namespaces to create validator instance by it's class name.
Validator will be created by class existence in this namespaces order.
Validators namespaces array configured by default: array('\\MvcCore\\Ext\\Forms\\Validators\\'); .
Parameters
Returns
integer New validators namespaces count.
|