mvccore/ext-form-field-button

MvcCore - Extension - Form - Field - Button - form field types - button:submit, button:reset, input:submit, input:reset and image.

v5.3.0 2024-11-21 15:00 UTC

This package is auto-updated.

Last update: 2024-11-21 16:00:14 UTC


README

Latest Stable Version License PHP Version

MvcCore form extension with fields based on elements <button> and <input> with types button, submit and reset.

Installation

composer require mvccore/ext-form-field-button

Fields

There are no validator for any button field in this package.

  • input:button
  • input:reset
  • input:submit
  • input:image
  • button:button
  • button:reset
  • button:submit

Features

  • always server side checked attributes required, disabled and readonly
  • 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() ...
    • Submit() - called on every instance when form is submitted

Examples

Basic Example

$form = (new \MvcCore\Ext\Form($controller))->SetId('demo');
...
// buttons has not labels, only values:
$reset = new \MvcCore\Ext\Forms\Fields\ResetInput();
$reset
	->SetName('reset_form')
	->SetValue('Clean all values:');
$submit = new \MvcCore\Ext\Forms\Fields\SubmitButton([
	'name'		=> 'send',
	'value'		=> 'Save',
]);
...
$form->AddFields($reset, $submit);