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\SelectIndirect 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
public
|
|
public
|
|
public
|
|
public
|
#
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'. |
public
|
#
SetRequired( boolean $required = TRUE )
Set required boolean if field will be required to complete by user for submit. |
public
|
#
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. |
public
|
#
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 |
public
|
|
public
string|array
|
|
public
|
#
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. |
public
|
#
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. |
public
|
#
SetCssClasses( string $cssClasses )
Set value to control html class attribute. More classes is necessary to set as strings separated by spaces. |
public
|
#
AddCssClass( string $cssClass )
Add value to html class attribute. More classes is necessary to add as strings separated by spaces. |
public
|
#
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... |
public
|
#
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. |
public
|
#
SetLabelAttrs( array $attrs = array() )
Set any additional control html attributes by key/value array. |
public
|
#
AddLabelAttr( array $attr = array() )
Add any additional control html attributes by key/value array. |
public
|
#
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. |
public
|
#
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. |
public
|
#
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. |
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
#
OnAdded(
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 |
public
|
|
public
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. |
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. |
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. |
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. |
public
string
|
|
public
string
|
|
public
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. |
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. |
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. |
public
string
|
$Id
Form control html id |
#
''
|
public
string
|
$Type
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. |
#
''
|
public
string
|
$Value
Form control value. |
#
''
|
public
string
|
$Label
Form control label visible text, text only. |
#
''
|
public
string
|
$LabelSide
Location where to render |
#
'left'
|
public
boolean
|
$Required
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. |
#
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. |
#
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. |
#
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. |
#
NULL
|
public
array
|
$CssClasses
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. |
#
array()
|
public
array
|
$LabelAttrs
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'. |
#
array()
|
public
string[]
|
$Errors
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. |
#
''
|
public
|
$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. |
#
NULL
|
public
string
|
$JsClass
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; |
#
''
|
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; |
#
''
|
public
|
$Form
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. |
#
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. |
#
array(
'Id', 'View', 'Form', 'Field',
)
|