mvccore / ext-form-field-numeric
MvcCore - Extension - Form - Field - Numeric - form field types - input:number and input:range.
Installs: 467
Dependents: 8
Suggesters: 3
Security: 0
Stars: 2
Watchers: 1
Forks: 1
Open Issues: 0
pkg:composer/mvccore/ext-form-field-numeric
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 IntlPHP extension
- min., max. and step validation
 
- Integer- not configured by default
- the same validation as Number, only withintchecking (if there are precision values or not)
 
- Float- not configured by default
- the same validation as Number, only returning alwaysfloattype
 
 
- input:range(extended from- input:number)- Range- configured by default
- directly extended from Numbervaludator, the same functionality only for 2 numbers
 
 
Features
- always server side checked attributes required,disabledandreadonly
- 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 instance
- PreDispatch()- called immediatelly before any field instance rendering type
- Render()- 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);