jarzon / forms
Form generator/validator
Installs: 36
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 0
Open Issues: 6
Type:project
Requires
- php: >=8.1.0
Requires (Dev)
- mikey179/vfsstream: ~1.6.0
- phpstan/phpstan: ^0.12.0
- phpunit/phpunit: ^9.5.0
- dev-master
- v1.32.3
- v1.21.3
- v1.21.2
- v1.13.10
- v1.13.9
- v1.13.8
- v1.13.7
- v1.13.6
- v1.13.5
- v1.13.4
- v1.13.3
- v1.13.2
- v1.13.1
- v1.13.0
- v1.12.1
- v1.12.0
- v1.11.3
- v1.11.2
- v1.11.1
- v1.11.0
- v1.9.32
- v1.9.31
- 1.9.30
- v1.9.29
- v1.9.28
- v1.9.27
- v1.9.26
- v1.9.25
- v1.9.24
- v1.9.23
- v1.9.22
- v1.9.21
- v1.9.20
- v1.9.19
- v1.9.18
- v1.9.17
- v1.9.16
- v1.9.15
- v1.9.14
- v1.9.13
- v1.9.12
- v1.9.11
- v1.9.10
- v1.9.9
- v1.9.8
- v1.9.7
- v1.9.6
- v1.9.5
- v1.9.4
- v1.9.3
- v1.9.2
- v1.9.1
- v1.9.0
- v1.8.1
- v1.8.0
- v1.7.21
- v1.7.20
- v1.7.19
- v1.7.18
- v1.7.17
- v1.7.16
- v1.7.15
- v1.7.14
- v1.7.13
- v1.7.12
- v1.7.11
- v1.7.10
- v1.7.9
- v1.7.8
- v1.7.7
- v1.7.6
- v1.7.5
- v1.7.4
- v1.7.3
- v1.7.2
- v1.7.1
- v1.7.0
- v1.6.0
- v1.5.16
- v1.5.15
- v1.5.14
- v1.5.13
- v1.5.12
- v1.5.11
- 1.5.10
- v1.5.9
- v1.5.8
- v1.5.7
- v1.5.6
- v1.5.5
- v1.5.4
- v1.5.3
- v1.5.2
- v1.5.1
- v1.5.0
- v1.4.5
- v1.4.4
- v1.4.3
- v1.4.2
- v1.4.1
- v1.4.0
- v1.3.15
- v1.3.14
- v1.3.13
- v1.3.12
- v1.3.11
- v1.3.10
- v1.3.9
- v1.3.8
- v1.3.7
- v1.3.6
- v1.3.5
- v1.3.4
- v1.3.3
- v1.3.2
- v1.3.1
- v1.3.0
- v1.2.1
- v1.2.0
- v1.1.0
- v1.0.0
- v0.3.13
- v0.1.7
- v0.1.6
- v0.1.5
- v0.1.4
- v0.1.3.5
- v0.1.3
- v0.1.2
- v0.1.1
- v0.1.0
- dev-InputCollection
This package is auto-updated.
Last update: 2024-11-30 20:53:16 UTC
README
Install
composer require jarzon/form
Usage
Build the form
<?php $form = new Jarzon\Form($_POST); // Create your form $form ->text('name') ->min(2) ->max(100) ->required() ->placeholder('Joe Doe') ->number('age') ->min(0) ->max(100) ->submit();
Show the form in the view
<?=$form('form')->html?> <div><?=$form('name')->label('Name:')->row?></div> <div><?=$form('age')->label('Age:')->row?></div> <?=$form('submit')->value('Save')->html?> <?=$form('/form')->html?>
Process the form values
<?php // On submit validate the form values if($form->submitted()) { try { // Does the validation based on the inputs types, min/max, required if($values = $form->validation()) { // Do what you want with the returned values echo "Your name is {$values['name']}"; } } catch (\Jarzon\Form\ValidationException $e) { // ->validation() throw a custom Exception if there is an invalid value echo "Error: {$e->getMessage()}"; } }