Overview

Namespaces

  • MvcCore
    • Ext
      • Auth
        • Virtual
      • Debug
        • Tracy
      • Form
        • Core
        • Validators
      • Request
      • Router
        • Lang
      • View
        • Helpers
  • None

Classes

  • Base
  • Configuration
  • Field
  • FieldGroup
  • Helpers
  • Validator
  • View

Exceptions

  • Exception
  • Overview
  • Namespace
  • Class
  • Tree

Class Field

Direct known subclasses

MvcCore\Ext\Form\Button, MvcCore\Ext\Form\Checkbox, MvcCore\Ext\Form\SubmitInput, MvcCore\Ext\Form\Text, MvcCore\Ext\Form\Textarea, MvcCore\Ext\Form\Core\FieldGroup, MvcCore\Ext\Form\Date, MvcCore\Ext\Form\Hidden, MvcCore\Ext\Form\NoType, MvcCore\Ext\Form\Number, MvcCore\Ext\Form\Range, MvcCore\Ext\Form\ResetInput, MvcCore\Ext\Form\Select

Indirect known subclasses

MvcCore\Ext\Form\CheckboxGroup, MvcCore\Ext\Form\CountrySelect, MvcCore\Ext\Form\DateTime, MvcCore\Ext\Form\Email, MvcCore\Ext\Form\Password, MvcCore\Ext\Form\RadioGroup, MvcCore\Ext\Form\ResetButton, MvcCore\Ext\Form\SubmitButton, MvcCore\Ext\Form\Time
Abstract
Namespace: MvcCore\Ext\Form\Core
Located at ext-form/src/MvcCore/Ext/Form/Core/Field.php
Methods summary
public MvcCore\Ext\Form\Core\Field
# SetName( string $name )

Set field name, used to identify submitting value.

Set field name, used to identify submitting value.

Parameters

$name

Returns

MvcCore\Ext\Form\Core\Field

Requires

public MvcCore\Ext\Form\Core\Field
# SetType( string $type )

Set input type like: 'text', 'number', 'range'...

Set input type like: 'text', 'number', 'range'...

Parameters

$type

Returns

MvcCore\Ext\Form\Core\Field
public MvcCore\Ext\Form\Core\Field
# SetLabel( string $label )

Set control label visible text. Translation will be processed internaly inside Simpleform before rendering process by $this->Form->Translator();

Set control label visible text. Translation will be processed internaly inside Simpleform before rendering process by $this->Form->Translator();

Parameters

$label

Returns

MvcCore\Ext\Form\Core\Field
public MvcCore\Ext\Form\Core\Field
# SetLabelSide( string $labelSide = 'right' )

Set label side - location where label will be rendered. By default $this->LabelSide is configured to 'left'. If you want to reconfigure it to different side, next possible value is 'right'.

Set label side - location where label will be rendered. By default $this->LabelSide is configured to 'left'. If you want to reconfigure it to different side, next possible value is 'right'.

Parameters

$labelSide

Returns

MvcCore\Ext\Form\Core\Field
public MvcCore\Ext\Form\Core\Field
# SetRequired( boolean $required = TRUE )

Set required boolean if field will be required to complete by user for submit.

Set required boolean if field will be required to complete by user for submit.

Parameters

$required

Returns

MvcCore\Ext\Form\Core\Field
public MvcCore\Ext\Form\Core\Field
# SetReadonly( boolean $readonly = TRUE )

Set read only boolean if field will be read only, not possible to complete by user for submit, result value will be used from session.

Set read only boolean if field will be read only, not possible to complete by user for submit, result value will be used from session.

Parameters

$readonly

Returns

MvcCore\Ext\Form\Core\Field
public MvcCore\Ext\Form\Core\Field
# SetRenderMode( string $renderMode = \MvcCore\Ext\Form\Core\Configuration::FIELD_RENDER_MODE_LABEL_AROUND )

Set field render mode to render label normaly before control by value 'normal', which controls have mostly configured by default or to render label around the control by value 'label-around' or to not render any label by value 'no-label'. Use \MvcCore\Ext\Form class constants: - \MvcCore\Ext\Form::FIELD_RENDER_MODE_NORMAL - \MvcCore\Ext\Form::FIELD_RENDER_MODE_LABEL_AROUND - \MvcCore\Ext\Form::FIELD_RENDER_MODE_NO_LABEL

Set field render mode to render label normaly before control by value 'normal', which controls have mostly configured by default or to render label around the control by value 'label-around' or to not render any label by value 'no-label'. Use \MvcCore\Ext\Form class constants: - \MvcCore\Ext\Form::FIELD_RENDER_MODE_NORMAL - \MvcCore\Ext\Form::FIELD_RENDER_MODE_LABEL_AROUND - \MvcCore\Ext\Form::FIELD_RENDER_MODE_NO_LABEL

Parameters

$renderMode

Returns

MvcCore\Ext\Form\Core\Field
public MvcCore\Ext\Form\Core\Field
# SetValue( string|array|mixed $value )

Set control value, should be string or array, by field type implementation.

Set control value, should be string or array, by field type implementation.

Parameters

$value

Returns

MvcCore\Ext\Form\Core\Field
public string|array
# GetValue( )

Get control value, should be string or array, by field type implementation.

Get control value, should be string or array, by field type implementation.

Returns

string|array
public MvcCore\Ext\Form\Core\Field
# SetTranslate( boolean $translate = TRUE )

Set translate to TRUE if you want to translate this field. It is necessary to set up any $form->Translator callable to translate cotnrol placeholder, label and error messages.

Set translate to TRUE if you want to translate this field. It is necessary to set up any $form->Translator callable to translate cotnrol placeholder, label and error messages.

Parameters

$translate

Returns

MvcCore\Ext\Form\Core\Field
public MvcCore\Ext\Form\Core\Field
# SetDisabled( boolean $disabled )

Set disabled boolean if field will be disabled for user, not possible to complete by user for submit and disabled in submitting process, result value will be used from session.

Set disabled boolean if field will be disabled for user, not possible to complete by user for submit and disabled in submitting process, result value will be used from session.

Parameters

$disabled
$readonly

Returns

MvcCore\Ext\Form\Core\Field
public MvcCore\Ext\Form\Core\Field
# SetCssClasses( string $cssClasses )

Set value to control html class attribute. More classes is necessary to set as strings separated by spaces.

Set value to control html class attribute. More classes is necessary to set as strings separated by spaces.

Parameters

$cssClasses

Returns

MvcCore\Ext\Form\Core\Field
public MvcCore\Ext\Form\Core\Field
# AddCssClass( string $cssClass )

Add value to html class attribute. More classes is necessary to add as strings separated by spaces.

Add value to html class attribute. More classes is necessary to add as strings separated by spaces.

Parameters

$cssClass
$cssClasses

Returns

MvcCore\Ext\Form\Core\Field
public MvcCore\Ext\Form\Core\Field
# SetControlAttrs( array $attrs = array() )

Set any additional control html attributes by key/value array. Do not use system attributes as id, name, value, readonly, disabled, class...

Set any additional control html attributes by key/value array. Do not use system attributes as id, name, value, readonly, disabled, class...

Parameters

$attrs

Returns

MvcCore\Ext\Form\Core\Field
public MvcCore\Ext\Form\Core\Field
# AddControlAttr( array $attr = array() )

Add any additional control html attributes by key/value array. Do not use system attributes as id, name, value, readonly, disabled, class... Use specific setter for them.

Add any additional control html attributes by key/value array. Do not use system attributes as id, name, value, readonly, disabled, class... Use specific setter for them.

Parameters

$attr
$attrs

Returns

MvcCore\Ext\Form\Core\Field
public MvcCore\Ext\Form\Core\Field
# SetLabelAttrs( array $attrs = array() )

Set any additional control html attributes by key/value array.

Set any additional control html attributes by key/value array.

Parameters

$attrs

Returns

MvcCore\Ext\Form\Core\Field
public MvcCore\Ext\Form\Core\Field
# AddLabelAttr( array $attr = array() )

Add any additional control html attributes by key/value array.

Add any additional control html attributes by key/value array.

Parameters

$attr
$attrs

Returns

MvcCore\Ext\Form\Core\Field
public MvcCore\Ext\Form\Core\Field
# SetValidators( string[]|Closure[] $validators = array() )

Set field validators collection, it shoud be validator class end-name in pascal case or closure function. All validators are located in /Form/Validators/... dir. So for validator class \MvcCore\Ext\Form\Validators\Numeric is necessary only to set array('Numeric'). Or any validator shoud be defined as simple closure function accepting arguments: $submitValue, $fieldName, \MvcCore\Ext\Form\Core\Field & $field and returnning safe value as result. This closure function shoud call $field->Form->AddError(); whenever is necessary and values is not correct.

Set field validators collection, it shoud be validator class end-name in pascal case or closure function. All validators are located in /Form/Validators/... dir. So for validator class \MvcCore\Ext\Form\Validators\Numeric is necessary only to set array('Numeric'). Or any validator shoud be defined as simple closure function accepting arguments: $submitValue, $fieldName, \MvcCore\Ext\Form\Core\Field & $field and returnning safe value as result. This closure function shoud call $field->Form->AddError(); whenever is necessary and values is not correct.

Parameters

$validators

Returns

MvcCore\Ext\Form\Core\Field
public MvcCore\Ext\Form\Core\Field
# AddValidators( )

Add field validators, it shoud be validator class end-name in pascal case or closure function. All validators are located in /Form/Validators/... dir. So for validator class \MvcCore\Ext\Form\Validators\Numeric is necessary only to set array('Numeric'). Or any validator shoud be defined as simple closure function accepting arguments: $submitValue, $fieldName, \MvcCore\Ext\Form\Core\Field & $field and returnning safe value as result. This closure function shoud call $field->Form->AddError(); whenever is necessary and values is not correct.

Add field validators, it shoud be validator class end-name in pascal case or closure function. All validators are located in /Form/Validators/... dir. So for validator class \MvcCore\Ext\Form\Validators\Numeric is necessary only to set array('Numeric'). Or any validator shoud be defined as simple closure function accepting arguments: $submitValue, $fieldName, \MvcCore\Ext\Form\Core\Field & $field and returnning safe value as result. This closure function shoud call $field->Form->AddError(); whenever is necessary and values is not correct.

Returns

MvcCore\Ext\Form\Core\Field
public MvcCore\Ext\Form\Core\Field
# SetTemplatePath( string $templatePath = '' )

Set template relative path without .phtml extension, if you want to render field by custom template. Empty string by default to render field naturaly. If there is configured any path, relative from directory /App/Views/Scripts, field is rendered by custom template.

Set template relative path without .phtml extension, if you want to render field by custom template. Empty string by default to render field naturaly. If there is configured any path, relative from directory /App/Views/Scripts, field is rendered by custom template.

Parameters

$templatePath

Returns

MvcCore\Ext\Form\Core\Field
public MvcCore\Ext\Form\Core\Field
# SetJsClass( string $jsClass )

Set supporting javascript full class name.

Set supporting javascript full class name.

Parameters

$jsClass

Returns

MvcCore\Ext\Form\Core\Field
public MvcCore\Ext\Form\Core\Field
# SetJs( string $jsFullFile )

Set supporting javascript file relative path. Replacement 'MVCCORE_FORM_DIR' is in rendering process replaced by \MvcCore\Ext\Form library root dir or by any other reconfigured value from $this->Form->jsAssetsRootDir;

Set supporting javascript file relative path. Replacement 'MVCCORE_FORM_DIR' is in rendering process replaced by \MvcCore\Ext\Form library root dir or by any other reconfigured value from $this->Form->jsAssetsRootDir;

Parameters

$jsFullFile

Returns

MvcCore\Ext\Form\Core\Field
public MvcCore\Ext\Form\Core\Field
# SetCss( string $cssFullFile )

Set supporting css file relative path. Replacement 'MVCCORE_FORM_DIR' is in rendering process replaced by \MvcCore\Ext\Form library root dir or by any other reconfigured value from $this->Form->cssAssetsRootDir;

Set supporting css file relative path. Replacement 'MVCCORE_FORM_DIR' is in rendering process replaced by \MvcCore\Ext\Form library root dir or by any other reconfigured value from $this->Form->cssAssetsRootDir;

Parameters

$cssFullFile

Returns

MvcCore\Ext\Form\Core\Field
public MvcCore\Ext\Form\Core\Field
# AddError( string $errorText )

Add field error message. This method is always called internaly from \MvcCore\Ext\Form in render preparing process. Do not use it. To add form error properly, use $field->Form->AddError(); method isntead.

Add field error message. This method is always called internaly from \MvcCore\Ext\Form in render preparing process. Do not use it. To add form error properly, use $field->Form->AddError(); method isntead.

Parameters

$errorText

Returns

MvcCore\Ext\Form\Core\Field
public
# __construct( array $cfg = array() )

Create new form control instance.

Create new form control instance.

Parameters

$cfg

config array with camel case public properties and its values which you want to configure.

Throws

MvcCore\Ext\Form\Core\Exception
public
# __set( string $name, mixed $value )

Set any nondeclared property dynamicly to get it in view by rendering process.

Set any nondeclared property dynamicly to get it in view by rendering process.

Parameters

$name
$value
public
# OnAdded( MvcCore\Ext\Form & $form )

This method is called internaly from \MvcCore\Ext\Form after field is added into form by $form->AddField(); method. Do not use it if you are only user of this library. - 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

This method is called internaly from \MvcCore\Ext\Form after field is added into form by $form->AddField(); method. Do not use it if you are only user of this library. - 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

Parameters

$form

Throws

MvcCore\Ext\Form\Core\Exception
public
# SetUp( )

Set up field properties before rendering process. - set up field render mode - set up translation boolean - translate label if any

Set up field properties before rendering process. - set up field render mode - set up translation boolean - translate label if any

public string
# Render( )

Render field in full mode, naturaly or by custom template.

Render field in full mode, naturaly or by custom template.

Returns

string
public string
# RenderTemplate( )

Render field by configured template. This method creates $view = new \MvcCore\Ext\Form\Core\View sets all local context variables into it and renders it into string.

Render field by configured template. This method creates $view = new \MvcCore\Ext\Form\Core\View sets all local context variables into it and renders it into string.

Returns

string
public string
# RenderNaturally( )

Render field naturaly by render mode. Field shoud be rendered with label beside, label around or without label by local field configuration. Also there could be rendered specific field errors before or after field if field form is configured in that way.

Render field naturaly by render mode. Field shoud be rendered with label beside, label around or without label by local field configuration. Also there could be rendered specific field errors before or after field if field form is configured in that way.

Returns

string
public string
# RenderLabelAndControl( )

Render field control and label by local configuration in left or in right side, errors beside if form is configured to render specific errors beside controls.

Render field control and label by local configuration in left or in right side, errors beside if form is configured to render specific errors beside controls.

Returns

string
public string
# RenderControlInsideLabel( )

Render field control inside label by local configuration, render field errors beside if form is configured to render specific errors beside controls.

Render field control inside label by local configuration, render field errors beside if form is configured to render specific errors beside controls.

Returns

string
public string
# RenderControl( )

Render control tag only without label or specific errors.

Render control tag only without label or specific errors.

Returns

string
public string
# RenderLabel( )

Render label tag only without control or specific errors.

Render label tag only without control or specific errors.

Returns

string
public string
# RenderErrors( )

Render field specific errors only without control or label.

Render field specific errors only without control or label.

Returns

string
protected string
# renderLabelAttrsWithFieldVars( string[] $fieldVars = array() )

Complete HTML attributes and css classes strings for label element by selected field variables from $this field context only if called $fieldVars item in $this field context is something different then NULL value. Automaticly render into attributes and css classes also system field properties: 'Disabled', 'Readonly' and 'Required' in boolean mode. All named field context properties translate into attributes names and css classes strings from PascalCase into dashed-case.

Complete HTML attributes and css classes strings for label element by selected field variables from $this field context only if called $fieldVars item in $this field context is something different then NULL value. Automaticly render into attributes and css classes also system field properties: 'Disabled', 'Readonly' and 'Required' in boolean mode. All named field context properties translate into attributes names and css classes strings from PascalCase into dashed-case.

Parameters

$fieldVars

Returns

string
protected string
# renderControlAttrsWithFieldVars( string[] $fieldVars = array() )

Complete HTML attributes and css classes strings for control element by selected field variables from $this field context only if called $fieldVars item in $this field context is something different then NULL value. Automaticly render into attributes and css classes also system field properties: 'Disabled', 'Readonly' and 'Required' in boolean mode. All named field context properties translate into attributes names and css classes strings from PascalCase into dashed-case.

Complete HTML attributes and css classes strings for control element by selected field variables from $this field context only if called $fieldVars item in $this field context is something different then NULL value. Automaticly render into attributes and css classes also system field properties: 'Disabled', 'Readonly' and 'Required' in boolean mode. All named field context properties translate into attributes names and css classes strings from PascalCase into dashed-case.

Parameters

$fieldVars

Returns

string
protected string
# renderAttrsWithFieldVars( string[] $fieldVars = array(), array $fieldAttrs = array(), array $cssClasses = array(), boolean $controlRendering = FALSE )

Complete HTML attributes and css classes strings for label/control element by selected field variables from $this field context only if called $fieldVars item in $this field context is something different then NULL value. Automaticly render into attributes and css classes also system field properties: 'Disabled', 'Readonly' and 'Required' in boolean mode. All named field context properties translate into attributes names and css classes strings from PascalCase into dashed-case. Only if fourth param is false, do not add system attributes in boolean mode into attributes, only into css class.

Complete HTML attributes and css classes strings for label/control element by selected field variables from $this field context only if called $fieldVars item in $this field context is something different then NULL value. Automaticly render into attributes and css classes also system field properties: 'Disabled', 'Readonly' and 'Required' in boolean mode. All named field context properties translate into attributes names and css classes strings from PascalCase into dashed-case. Only if fourth param is false, do not add system attributes in boolean mode into attributes, only into css class.

Parameters

$fieldVars
$fieldAttrs
$cssClasses
$controlRendering

Returns

string
Properties summary
public string $Id

Form control html id

Form control html id

# ''
public string $Type

Form control type, usually used in attr value, but unique type accross all form field types.

Form control type, usually used in attr value, but unique type accross all form field types.

# ''
public string $Name

Form control specific name, server as key in submitting process where is sended it's used completed value.

Form control specific name, server as key in submitting process where is sended it's used completed value.

Requires

# ''
public string $Value

Form control value.

Form control value.

# ''
public string $Label

Form control label visible text, text only.

Form control label visible text, text only.

# ''
public string $LabelSide

Location where to render

Location where to render

# 'left'
public boolean $Required

Form control attribute required, determinating if controll will be required to complete by user.

Form control attribute required, determinating if controll will be required to complete by user.

# null
public boolean $Readonly

Form control attribute readonly, determinating if controll will be readonly to not completed by user, and readonly by submitting process - so only session value will be used.

Form control attribute readonly, determinating if controll will be readonly to not completed by user, and readonly by submitting process - so only session value will be used.

# FALSE
public boolean $Disabled

Form control attribute disabled, determinating if controll will be disabled to not completed by user, and disabled by submitting process - so only session value will be used.

Form control attribute disabled, determinating if controll will be disabled to not completed by user, and disabled by submitting process - so only session value will be used.

# FALSE
public boolean $Translate

Boolean telling if field will be translated or not. If nothing is configured as boolean, $field->Form->Translate values is used. If $field->Translate is TRUE, translated are placeholders, label texts and error messages.

Boolean telling if field will be translated or not. If nothing is configured as boolean, $field->Form->Translate values is used. If $field->Translate is TRUE, translated are placeholders, label texts and error messages.

# NULL
public string $RenderMode

Control/label rendering mode, defined in form by defaut as: 'normal'. Normal means label will be rendered before control, only for checkbox and radio buttons labels will be rendered after controls. Another possible values are 'no-label' and 'label-around'. Use \MvcCore\Ext\Form::FIELD_RENDER_MODE_NORMAL, \MvcCore\Ext\Form::FIELD_RENDER_MODE_NO_LABEL and \MvcCore\Ext\Form::FIELD_RENDER_MODE_LABEL_AROUND.

Control/label rendering mode, defined in form by defaut as: 'normal'. Normal means label will be rendered before control, only for checkbox and radio buttons labels will be rendered after controls. Another possible values are 'no-label' and 'label-around'. Use \MvcCore\Ext\Form::FIELD_RENDER_MODE_NORMAL, \MvcCore\Ext\Form::FIELD_RENDER_MODE_NO_LABEL and \MvcCore\Ext\Form::FIELD_RENDER_MODE_LABEL_AROUND.

# NULL
public array $CssClasses

Html element css class string value, more classes separated by space.

Html element css class string value, more classes separated by space.

# array()
public array $ControlAttrs

Collection with html element additional attributes by array keys/values.

Collection with html element additional attributes by array keys/values.

# array()
public array $LabelAttrs

Collection with html

Collection with html

# array()
public string[]|Closure[] $Validators

List of validator classes end-names or list of closure functions accepting arguments: $submitValue, $fieldName, \MvcCore\Ext\Form\Core\Field & $field and returning safe value as result. Closure function should call $field->Form->AddError() internaly if necessary and submitted value is not correct. All validator classes are located in directory: /Form/Validators/... For validator class \MvcCore\Ext\Form\Validators\Numeric is necessary only tu set 'Numeric'.

List of validator classes end-names or list of closure functions accepting arguments: $submitValue, $fieldName, \MvcCore\Ext\Form\Core\Field & $field and returning safe value as result. Closure function should call $field->Form->AddError() internaly if necessary and submitted value is not correct. All validator classes are located in directory: /Form/Validators/... For validator class \MvcCore\Ext\Form\Validators\Numeric is necessary only tu set 'Numeric'.

# array()
public string[] $Errors

Field instance errors for rendering process.

Field instance errors for rendering process.

# array()
public string $TemplatePath

Field relative template path without .phtml extension, empty string by default to render field naturaly. If there is configured any path, relative from directory /App/Views/Scripts, field is rendered by custom template.

Field relative template path without .phtml extension, empty string by default to render field naturaly. If there is configured any path, relative from directory /App/Views/Scripts, field is rendered by custom template.

# ''
public MvcCore\Ext\Form\Core\View $View

Form field view, object container with variables from local context to render in template. Created automaticly inside \MvcCore\Ext\Form\Core\Field before field rendering process.

Form field view, object container with variables from local context to render in template. Created automaticly inside \MvcCore\Ext\Form\Core\Field before field rendering process.

# NULL
public string $JsClass

Supporting javascript full class name.

Supporting javascript full class name.

# ''
public string $Js

Supporting javascript file relative path. Replacement 'MVCCORE_FORM_DIR' is in rendering process replaced by \MvcCore\Ext\Form library root dir or by any other reconfigured value from $this->Form->jsAssetsRootDir;

Supporting javascript file relative path. Replacement 'MVCCORE_FORM_DIR' is in rendering process replaced by \MvcCore\Ext\Form library root dir or by any other reconfigured value from $this->Form->jsAssetsRootDir;

# ''
public string $Css

Supporting css file relative path. Replacement 'MVCCORE_FORM_DIR' is in rendering process replaced by \MvcCore\Ext\Form library root dir or by any other reconfigured value from $this->Form->cssAssetsRootDir;

Supporting css file relative path. Replacement 'MVCCORE_FORM_DIR' is in rendering process replaced by \MvcCore\Ext\Form library root dir or by any other reconfigured value from $this->Form->cssAssetsRootDir;

# ''
public MvcCore\Ext\Form $Form

Form instance where current fields is placed.

Form instance where current fields is placed.

# NULL
public static array $Templates

Core rendering templates storrage. Those templates are used in form natural rendering process, form custom template rendering process, natural field rendering process but not by custom field rendering process.

Core rendering templates storrage. Those templates are used in form natural rendering process, form custom template rendering process, natural field rendering process but not by custom field rendering process.

# array( 'label' => '<label for="{id}"{attrs}>{label}</label>', 'control' => '<input id="{id}" name="{name}" type="{type}" value="{value}"{attrs} />', 'togetherLabelLeft' => '<label for="{id}"{attrs}><span>{label}</span>{control}</label>', 'togetherLabelRight'=> '<label for="{id}"{attrs}>{control}<span>{label}</span></label>', )
protected static string[] $declaredProtectedProperties

Local $this context properties which is not possible to configure throught constructor config array.

Local $this context properties which is not possible to configure throught constructor config array.

# array( 'Id', 'View', 'Form', 'Field', )
MvcCore API documentation generated by ApiGen