Methods summary
public
MvcCore\Ext\Form
|
#
SetId( string $id )
Set form id, required to configure.
Used to identify session data, error messages,
CSRF tokens, html form attribute id value and much more.
Set form id, required to configure.
Used to identify session data, error messages,
CSRF tokens, html form attribute id value and much more.
Parameters
Returns
Requires
|
public
MvcCore\Ext\Form
|
#
SetAction( string|null $url = NULL )
Set form submitting URL value.
It could be relative or absolute, anything
to complete classic html form attribute action .
Set form submitting URL value.
It could be relative or absolute, anything
to complete classic html form attribute action .
Parameters
Returns
|
public
MvcCore\Ext\Form
|
#
SetMethod( string $method = \MvcCore\Ext\IForm::METHOD_POST )
Set form http submitting method.POST by default.
Use GET only if form data contains only ASCII characters.
Possible values: 'POST' | 'GET'
You can use constants:
- \MvcCore\Ext\IForm::METHOD_POST
- \MvcCore\Ext\IForm::METHOD_GET
Set form http submitting method.POST by default.
Use GET only if form data contains only ASCII characters.
Possible values: 'POST' | 'GET'
You can use constants:
- \MvcCore\Ext\IForm::METHOD_POST
- \MvcCore\Ext\IForm::METHOD_GET
Parameters
Returns
|
public
MvcCore\Ext\Form
|
#
SetCssClasses( string|string[] $cssClasses )
Set form HTML element css classes strings.
All previously defined css classes will be removed.
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.
Set form HTML element css classes strings.
All previously defined css classes will be removed.
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
|
#
SetSuccessUrl( string|null $url = NULL )
Set form success submit URL string to redirect after, relative or absolute,
to specify, where to redirect user after form has been submitted successfully.
It's required to use \MvcCore\Ext\Form like this, if you want to use method
$form->SubmittedRedirect(); , at the end of custom Submit() method implementation,
you need to specify at least success and error URL strings.
Set form success submit URL string to redirect after, relative or absolute,
to specify, where to redirect user after form has been submitted successfully.
It's required to use \MvcCore\Ext\Form like this, if you want to use method
$form->SubmittedRedirect(); , at the end of custom Submit() method implementation,
you need to specify at least success and error URL strings.
Parameters
Returns
|
public
MvcCore\Ext\Form
|
#
SetErrorUrl( string|null $url = NULL )
Set form error submit URL string, relative or absolute, to specify,
where to redirect user after has not been submitted successfully.
It's not required to use \MvcCore\Ext\Form like this, but if you want to use method
$form->SubmittedRedirect(); at the end of custom Submit() method implementation,
you need to specify at least success and error URL strings.
Set form error submit URL string, relative or absolute, to specify,
where to redirect user after has not been submitted successfully.
It's not required to use \MvcCore\Ext\Form like this, but if you want to use method
$form->SubmittedRedirect(); at the end of custom Submit() method implementation,
you need to specify at least success and error URL strings.
Parameters
Returns
|
public
MvcCore\Ext\Form
|
#
SetTranslator( callable $translator = NULL )
Set translator to translate field labels, options, placeholders and error messages.
Translator has to be callable (it could be closure function or array
with class_name/instance and method name string). First argument
of callable has to be a translation key and second argument
has to be language string (en , de ...) to translate the key into.
Result of callable object has to be a string - translated key for called language.
Set translator to translate field labels, options, placeholders and error messages.
Translator has to be callable (it could be closure function or array
with class_name/instance and method name string). First argument
of callable has to be a translation key and second argument
has to be language string (en , de ...) to translate the key into.
Result of callable object has to be a string - translated key for called language.
Parameters
Returns
|
public
string
|
#
Init( )
Render whole <form> with all content into HTML string to display it.
- If form is not initialized, there is automatically
called $form->Init(); method.
- If form is not pre-dispatched for rendering, there is
automatically called $form->PreDispatch(); method.
- Create new form view instance and set up the view with local
context variables.
- Render form naturally or by custom template.
- Clean session errors, because errors should be rendered
only once, only when it's used and it's now - in this rendering process.
Render whole <form> with all content into HTML string to display it.
- If form is not initialized, there is automatically called $form->Init(); method.
- If form is not pre-dispatched for rendering, there is automatically called $form->PreDispatch(); method.
- Create new form view instance and set up the view with local context variables.
- Render form naturally or by custom template.
- Clean session errors, because errors should be rendered only once, only when it's used and it's now - in this rendering process.
Returns
string
|
public
MvcCore\Ext\Form
|
#
AddFields( MvcCore\Ext\Forms\Field[] $fields )
Add multiple fully configured form field instances,
function have infinite params with new field instances.
Add multiple fully configured form field instances,
function have infinite params with new field instances.
Parameters
- $fields
- Any
\MvcCore\Ext\Forms\IField fully configured instance to add into form.
Returns
|
public
MvcCore\Ext\Form
|
|
public
array
|
#
Submit( array & $rawRequestParams = [] )
Process standard low level submit process.
If no params passed as first argument, all params from object
\MvcCore\Application::GetInstance()->GetRequest() are used.
- If fields are not initialized - initialize them by calling $form->Init(); .
- Check maximum post size by php configuration if form is posted.
- Check cross site request forgery tokens with session tokens.
- Process all field values and their validators and call $form->AddError() where necessary.
AddError() method automatically switch $form->Result property to zero - 0 , it means error submit result.
Return array with form result, safe values from validators and errors array.
Process standard low level submit process.
If no params passed as first argument, all params from object
\MvcCore\Application::GetInstance()->GetRequest() are used.
- If fields are not initialized - initialize them by calling $form->Init(); .
- Check maximum post size by php configuration if form is posted.
- Check cross site request forgery tokens with session tokens.
- Process all field values and their validators and call $form->AddError() where necessary. AddError() method automatically switch $form->Result property to zero - 0 , it means error submit result.
Return array with form result, safe values from validators and errors array.
Parameters
- $rawRequestParams
- optional
Returns
array Array to list: array($form->Result, $form->Data, $form->Errors);
|
public
MvcCore\Ext\Form
|
#
ClearSession( )
Clear form values to empty array and clear form values in form session namespace,
clear form errors to empty array and clear form errors in form session namespace and
clear form CSRF tokens clear CRSF tokens in form session namespace.
Clear form values to empty array and clear form values in form session namespace,
clear form errors to empty array and clear form errors in form session namespace and
clear form CSRF tokens clear CRSF tokens in form session namespace.
Returns
|
public
|
#
SubmittedRedirect( )
Call this function in custom \MvcCore\Ext\Form::Submit(); method implementation
at the end of custom Submit() method to redirect user by configured success/error/prev/next
step URL address into final place and store everything into session.
You can also to redirect form after submit by yourself.
Call this function in custom \MvcCore\Ext\Form::Submit(); method implementation
at the end of custom Submit() method to redirect user by configured success/error/prev/next
step URL address into final place and store everything into session.
You can also to redirect form after submit by yourself.
|
public
string
|
#
__toString( )
Rendering process alias for \MvcCore\Ext\Form::Render(); .
Rendering process alias for \MvcCore\Ext\Form::Render(); .
Returns
string
|
public
string
|
#
Render( $controllerDashedName = '', $actionDashedName = '' )
Render whole <form> with all content into HTML string to display it.
- If form is not initialized, there is automatically
called $form->Init(); method.
- If form is not pre-dispatched for rendering, there is
automatically called $form->PreDispatch(); method.
- Create new form view instance and set up the view with local
context variables.
- Render form naturally or by custom template.
- Clean session errors, because errors should be rendered
only once, only when it's used and it's now - in this rendering process.
Render whole <form> with all content into HTML string to display it.
- If form is not initialized, there is automatically called $form->Init(); method.
- If form is not pre-dispatched for rendering, there is automatically called $form->PreDispatch(); method.
- Create new form view instance and set up the view with local context variables.
- Render form naturally or by custom template.
- Clean session errors, because errors should be rendered only once, only when it's used and it's now - in this rendering process.
Returns
string
|