2017 © Pedro Peláez
 

library form

Coordinates form validation, errors, messages, values, and inputs in a DRY KISS way.

image

bootpress/form

Coordinates form validation, errors, messages, values, and inputs in a DRY KISS way.

  • Thursday, January 19, 2017
  • by BootPress
  • Repository
  • 1 Watchers
  • 0 Stars
  • 738 Installations
  • PHP
  • 1 Dependents
  • 1 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

use BootPress\Form\Component as Form;

Packagist ![License MIT][badge-license] HHVM Tested ![PHP 7 Supported][badge-php] Build Status ![Code Climate][badge-code-climate] Test Coverage, (*1)

Coordinates form validation, errors, messages, values, and inputs in a DRY KISS way., (*2)

Installation

Add the following to your composer.json file., (*3)

``` bash { "require": { "bootpress/form": "^1.0" } }, (*4)


## Example Usage ```php <?php use BootPress\Form\Component as Form; $form = new Form('form', 'post'); // Create some menus $form->menu('gender', array( 'M' => 'Male', 'F' => 'Female', )); $form->menu('remember', array('Y' => 'Remember Me')); // Set the default values $form->set('values', array( 'name' => 'Daniel', 'email' => 'me@example.com', 'gender' => 'M', ));

Now the form's menus and default values have been set up, and you have a $form->validator object filled with $_POST vars, ready to go. You don't have to use the BootPress Validator Component, but it sure makes things easier for you., (*5)

$form->validator->set(array(
    'name' => 'required',
    'email' => 'required|email',
    'gender' => 'required|inList',
    'password' => 'required|minLength[5]|noWhiteSpace',
    'confirm' => 'required|matches[password]',
    'feedback' => 'maxWords[2]',
    'remember' => 'yesNo',
));

if ($vars = $form->validator->certified()) {
    echo '

'.print_r($vars, true).'
'; // $form->eject(); }

When you create a $form->menu(), we automatically pass it's values to the validator so that you can $form->validator->set('field', 'inList') with no params, and still be covered. That's why we didn't put 'inList[M,F]' for your gender above. To create the form:, (*6)

echo $form->header();
echo $form->fieldset('Form', array(
    $form->text('name', array('class' => 'form-control')),
    $form->text('email', array('placeholder' => 'Email Address')),
    $form->radio('gender'),
    $form->password('password'),
    $form->password('confirm'),
    $form->textarea('feedback'),
    $form->checkbox('remember'),
    $form->input('submit', array('name' => 'Submit')),
));
echo $form->close();

That would give you the following HTML:, (*7)



Form

You may want to put some labels and error messages in there, but this Form component is meant to be a bare-bones, just-get-the-hard-stuff-done first, so that you can style it anyway you like., (*8)

License

The MIT License (MIT). Please see License File for more information., (*9)

The Versions

19/01 2017

dev-master

9999999-dev https://www.bootpress.org/components/form.html

Coordinates form validation, errors, messages, values, and inputs in a DRY KISS way.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Kyle Gadd

20/10 2016

v1.0

1.0.0.0

Coordinates form validation, errors, messages, values, and inputs in a DRY KISS way.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Kyle Gadd