mvccore / ext-form-field-numeric
MvcCore - Extension - Form - Field - Numeric - form field types - input:number and input:range.
v5.3.0
2024-11-21 15:01 UTC
Requires
- php: >=5.4.0
- mvccore/ext-form: ^5.3
- mvccore/ext-tool-locale-floatparser: ^5.3
- mvccore/mvccore: ^5.3
Suggests
- mvccore/ext-form-validator-special: MvcCore form extension with special text and numeric validators.
README
MvcCore form extension with input field types number and range.
Installation
composer require mvccore/ext-form-field-numeric
Fields And Default Validators
input:number
Number
- configured by default
- raw user input parsing by specific rules to parse int/float or by
Intl
PHP extension - min., max. and step validation
Integer
- not configured by default
- the same validation as
Number
, only withint
checking (if there are precision values or not)
Float
- not configured by default
- the same validation as
Number
, only returning alwaysfloat
type
input:range
(extended frominput:number
)Range
- configured by default
- directly extended from
Number
valudator, the same functionality only for 2 numbers
Features
- always server side checked attributes
required
,disabled
andreadonly
- all HTML5 specific and global atributes (by Mozilla Development Network Docs)
- every field has it's build-in specific validator described above
- every build-in validator adds form error (when necessary) into session and than all errors are displayed/rendered and cleared from session on error page, where user is redirected after submit
- any field is possible to render naturally or with custom template for specific field class/instance
- very extensible field classes - every field has public template methods:
SetForm()
- called immediatelly after field instance is added into form instancePreDispatch()
- called immediatelly before any field instance rendering typeRender()
- called on every instance in form instance rendering process- submethods:
RenderNaturally()
,RenderTemplate()
,RenderControl()
,RenderLabel()
...
- submethods:
Submit()
- called on every instance when form is submitted
Examples
- Example - CD Collection (mvccore/example-cdcol)
- Application - Questionnaires (mvccore/app-questionnaires)
Basic Example
$form = (new \MvcCore\Ext\Form($controller))->SetId('demo'); ... $yourAge = new \MvcCore\Ext\Forms\Fields\Number(); $yourAge ->SetName('your_age') ->SetLabel('Your Age') ->SetMin(0) ->SetMax(130) ->SetStep(1) ->SetValidators('Integer'); $schoolAge = new \MvcCore\Ext\Forms\Fields\Range([ 'name' => 'school_age', 'label' => 'Your school age from/to', 'min' => 0, 'max' => 130, 'step' => 1, 'validators' => ['Range'], ]); ... $form->AddFields($yourAge, $schoolAge);