2017 © Pedro Peláez
 

library form

Simple, Object oriented forms for PHP.

image

seanmorris/form

Simple, Object oriented forms for PHP.

  • Tuesday, July 24, 2018
  • by seanmorris
  • Repository
  • 1 Watchers
  • 1 Stars
  • 87 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 8 Versions
  • 142 % Grown

The README.md

SeanMorris\Form

Rapid, themable forms for PHP.

Build Status Latest Stable Version Total Downloads Latest Unstable Version License, (*1)

The Form library allows you to rapidly develop, theme, and validate forms, so you can get back to programming., (*2)

Creating a Form

Creating a form is simple. Elements starting with a letter or number are fields. Elements starting with underscores are special keys. For example _method allows you to set the choose a GET or POST request for your form., (*3)

Elements starting with a letter or number are rendered directly into the <input> or <select> tag. Elements beginning with an underscore are passed to logic but not rendered., (*4)

For example, the _title attribute generates a <label tag for the form field., (*5)

$skeleton['_method'] = 'POST';

$skeleton['testField'] = [
  'type' => 'text'
  , '_title' => 'Test Field'
];

$skeleton['submit'] = [
  '_title' => 'Submit'
  , 'type' => 'submit'
];

$form = new \SeanMorris\Form\Form($skeleton);

echo $form->render();

Validation

Validators are specified on the _validators key. Its an array keyed by validator class. The values are arrays of arguments to pass to the constructor., (*6)

$skeleton['testField'] = [
  'type' => 'text'
  , '_title' => 'Test Field'
  , '_validators' => [
    'SeanMorris\Form\Validator\Regex' => [
      '/.{8,}/' => '%s must be at least 8 characters'
    ]
  ]
];

Filtering and validating submitted values is simple:, (*7)

$form->setValues($_POST);

if($form->validate())
{
  // Values will only contain keys for each of the fields.
  $values = $form->getValues();
}
else
{
  $errors = $form->erorrs();
}

More...

For the field type list, validator list, and usage guide read DOCS., (*8)

For the guide to extending the library to create new field types, read EXTENDING., (*9)

For legal information, check LICENSE and NOTICE., (*10)

README, (*11)

The Versions

24/07 2018

dev-master

9999999-dev

Simple, Object oriented forms for PHP.

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

by Sean Morris

24/07 2018

1.0.3

1.0.3.0

Simple, Object oriented forms for PHP.

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

by Sean Morris

27/12 2017

1.0.3rc

1.0.3.0-RC

Simple, Object oriented forms for PHP.

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

by Sean Morris

28/02 2016

1.0.2p

1.0.2.0-patch

Simple, Object oriented forms for PHP.

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

by Sean Morris

28/02 2016

1.0.2

1.0.2.0

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

by Sean Morris

28/02 2016

1.0.1

1.0.1.0

  Sources   Download

The Requires

 

The Development Requires

by Sean Morris

28/02 2016

1.0.0

1.0.0.0

  Sources   Download

The Requires

 

The Development Requires

by Sean Morris

28/02 2016

0.0.9

0.0.9.0

  Sources   Download

The Requires

 

The Development Requires

by Sean Morris