Methods summary
public
|
#
__construct( MvcCore\Controller |mixed & $controller )
Create \MvcCore\Ext\Form instance.
Please don't forget to configure at least $form->Id, $form->Action,
any control to work with and finaly any button:submit/input:submit
to submit the form to any url defined in $form->Action.
Create \MvcCore\Ext\Form instance.
Please don't forget to configure at least $form->Id, $form->Action,
any control to work with and finaly any button:submit/input:submit
to submit the form to any url defined in $form->Action.
Parameters
|
public
string
|
#
__toString( )
Rendering process alias.
Returns
string
See
\MvcCore\Ext\Form::Render();
|
public
MvcCore\Ext\Form
|
#
AddError( string $errorMsg, string $fieldName = '' )
Add form submit error and switch form result to zero - error state.
Add form submit error and switch form result to zero - error state.
Parameters
- $errorMsg
- $fieldName
- optional
Returns
|
public
MvcCore\Ext\Form
|
|
public
MvcCore\Ext\Form
|
#
AddFields( )
Add multiple configured form field instances,
function have infinite params with new field instances.
Add multiple configured form field instances,
function have infinite params with new field instances.
Returns
|
public
MvcCore\Ext\Form
|
#
UnsetEmptyData( )
Unset submitted $form->Data records wchid are empty string or empty array.
Unset submitted $form->Data records wchid are empty string or empty array.
Returns
|
public
|
#
ClearSession( )
Clear all session records for this form by form id.
Data sended from last submit, any csrf tokens and any errors.
Clear all session records for this form by form id.
Data sended from last submit, any csrf tokens and any errors.
|
public
stdClass
|
#
GetCsrf( )
Return current cross site request forgery hidden
input name and it's value as stdClass.
Result stdClass elements has keys 'name' and 'value'.
Return current cross site request forgery hidden
input name and it's value as stdClass.
Result stdClass elements has keys 'name' and 'value'.
Returns
stdClass
|
public
MvcCore\Ext\Form\Core\Field |null
&
|
#
GetField( string $fieldName = '' )
Return form field instance by form field name if it exists, else return null;
Return form field instance by form field name if it exists, else return null;
Parameters
Returns
|
public
MvcCore\Ext\Form\Core\Field[]
&
|
#
GetFieldsByType( string $fieldType = '' )
Return form field instances by field type string
Return form field instances by field type string
Parameters
Returns
|
public
MvcCore\Ext\Form\Core\Field[]
&
|
#
GetFieldsByClass( string $fieldClassName = '', boolean $directTypesOnly = FALSE )
Return form field instances by field class name
compared by 'is_a($field, $fieldClassName)' check
Return form field instances by field class name
compared by 'is_a($field, $fieldClassName)' check
Parameters
- $fieldClassName
- $directTypesOnly
- Get only instances created directly from called type, no extended instances
Returns
|
public
MvcCore\Ext\Form\Core\Field |null
&
|
#
GetFirstFieldsByClass( string $fieldClassName = '', boolean $directTypesOnly = FALSE )
Return first catched form field instance by field class name
compared by 'is_a($field, $fieldClassName)' check
Return first catched form field instance by field class name
compared by 'is_a($field, $fieldClassName)' check
Parameters
- $fieldClassName
- $directTypesOnly
- Get only instances created directly from called type, no extended instances
Returns
|
public
MvcCore\Ext\Form
|
#
Init( )
Initialize the form, check if we are initialized or not and do it only once,
check if any form id exists and initialize translation boolean for better field initializations.
This is template method. To define any fields in custom \MvcCore\Ext\Form class extension,
do it in Init method and call parent method as first line inside your custom Init method.
Initialize the form, check if we are initialized or not and do it only once,
check if any form id exists and initialize translation boolean for better field initializations.
This is template method. To define any fields in custom \MvcCore\Ext\Form class extension,
do it in Init method and call parent method as first line inside your custom Init method.
Returns
Throws
|
public
|
#
Prepare( )
Prepare form and it's fields for rendering.
This function is called automaticly by rendering process if necessary.
But if you need to operate with fields in your controller before rendering
with real session values and initialized session errors, you can call this
method anytime to prepare form for rendering and operate with anything inside.
Prepare form and it's fields for rendering.
This function is called automaticly by rendering process if necessary.
But if you need to operate with fields in your controller before rendering
with real session values and initialized session errors, you can call this
method anytime to prepare form for rendering and operate with anything inside.
|
public
|
#
RedirectAfterSubmit( )
After every custom $form->Submit(); function implementation is at the end,
call this function to redirect user by configured success/error/next step address
into final place and store everything into session.
After every custom $form->Submit(); function implementation is at the end,
call this function to redirect user by configured success/error/next step address
into final place and store everything into session.
|
public
MvcCore\Ext\Form
|
#
RemoveField( string $fieldName = '' )
Remove configured form field instance by field name.
Remove configured form field instance by field name.
Parameters
Returns
|
public
string
|
#
Render( )
Rendering process.
- if forms is not initialized, there is automaticly
called $form->Init(); method
- if form is not prepared for rendering, there is
automaticly called $form->prepareForRendering(); method
- create new form view instance and set up the view with local
context variables
- render form naturaly or by custom template
- clean session errors, because errors shoud be rendered
only once, only when it's used and it is now in rendering process
Rendering process.
- if forms is not initialized, there is automaticly called $form->Init(); method
- if form is not prepared for rendering, there is automaticly called $form->prepareForRendering(); method
- create new form view instance and set up the view with local context variables
- render form naturaly or by custom template
- clean session errors, because errors shoud be rendered only once, only when it's used and it is now in rendering process
Returns
string
|
public
string
|
#
RenderContent( )
Render form content.
Go through all $form->Fields and call $field->Render(); on every field
and put it into an empty
<
div> element. Render each field in full possible
way - naturaly by label configuration with possible errors configured beside
or with custom field template.
Render form content.
Go through all $form->Fields and call $field->Render(); on every field
and put it into an empty
<
div> element. Render each field in full possible
way - naturaly by label configuration with possible errors configured beside
or with custom field template.
Returns
string
|
public
string
|
#
RenderErrors( )
Render form errors.
If form is configured to render all errors together at form beginning,
this function completes all form errors into div.errors with div.error elements
inside containing each single errors message.
Render form errors.
If form is configured to render all errors together at form beginning,
this function completes all form errors into div.errors with div.error elements
inside containing each single errors message.
Returns
string
|
public
string
|
#
RenderBegin( )
Render form begin.
Render opening
<
form> tag and hidden input with csrf tokens.
Render form begin.
Render opening
<
form> tag and hidden input with csrf tokens.
Returns
string
|
public
string
|
#
RenderEnd( )
Render form end.
Render html closing tag and supporting javascript and css files
if is form not using external js/css renderers.
Render form end.
Render html closing tag and supporting javascript and css files
if is form not using external js/css renderers.
Returns
string
|
public
string
|
#
RenderCss( )
Render all supporting css files directly
as |