mvccore / ext-form-field-date
MvcCore - Extension - Form - Field - Date - form field types - input:date, input:datetime-local, input:time, input:week and input:month.
v5.2.5
2024-02-19 15:46 UTC
Requires
- php: >=5.4.0
- mvccore/ext-form: ^5.2.17
- mvccore/mvccore: ^5.2.28
README
MvcCore form extension with input field types date, datetime, time, week and month.
Installation
composer require mvccore/ext-form-field-date
Fields And Default Validators
input:date
Date
- configured by default
- validate submitted value format, min., max., step and dangerous characters
input:datetime-local
(extended frominput:date
)DateTime
- configured by default
- validate submitted value format, min., max., step and dangerous characters
input:time
(extended frominput:date
)Time
- configured by default
- validate submitted value format, min., max., step and dangerous characters
input:week
(extended frominput:date
)Week
- configured by default
- validate submitted value format, min., max., step and dangerous characters
input:month
(extended frominput:date
)Month
- configured by default
- validate submitted value format, min., max., step and dangerous characters
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
Basic Example
$form = (new \MvcCore\Ext\Form($controller))->SetId('demo'); ... $currentYear = intval(date("Y")); $bornDate = new \MvcCore\Ext\Forms\Fields\Date(); $bornDate ->SetName('born_date') ->SetLabel('I was born:') //->SetFormat('Y-m-d') // not required, 'Y-m-d' by default ->SetMin($currentYear - 130) ->SetMax($currentYear); $myMorningTime = new \MvcCore\Ext\Forms\Fields\Time([ 'name' => 'my_morning', 'label' => 'I usually get up at morning at:', //'format' => 'H:i', // not required, 'H:i' by default 'min' => '4:00', 'max' => '10:00', 'step' => 60 * 15, // 15 minutes ]); ... $form->AddFields($bornDate, $myMorningTime);