2017 © Pedro Peláez
 

library form

Describe collections of HTML form inputs

image

jnjxp/form

Describe collections of HTML form inputs

  • Wednesday, September 6, 2017
  • by jnj
  • Repository
  • 1 Watchers
  • 0 Stars
  • 67 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 1 Open issues
  • 5 Versions
  • 3 % Grown

The README.md

jnjxp.form

Describe collections of HTML form inputs, (*1)

Latest version ![Build Status][ico-travis] Coverage Status ![Quality Score][ico-code-quality], (*2)

Installation

composer require jnjxp/form

Usage

$form = (new Jnjxp\Form\FieldFactory)->newFieldCollection();

$form->add('username')
    ->type('text')
    ->label('Username')
    ->attribs(['required' => true])
    ->help('Enter username or email address');

$form->add('password')
    ->type('password')
    ->label('Password')
    ->attribs(['required' => true]);

$data = $filter->apply($input);
$form->fill($data);
$form->errors($filter->getFailures()->getMessages());


foreach ($form as $field) {

    $group = ['form-group'];
    $label = ['class' => 'control-label'];

    if ($field->id) {
        $group[] = 'form-group_' . $field->id;
        $label['for'] = $field->id;
    }

    if ($field->errors) {
        $group[] = 'has-errors';
    }

    echo $helper->tag('div', ['class' => $group]);

    if ($field->label) {
        echo PHP_EOL;
        echo $helper->label($field->label, $label);
    }

    echo PHP_EOL;
    echo $helper->input($field->spec);

    if ($field->help) {
        echo PHP_EOL;
        echo $helper->tag('p', ['class' => 'help-block']);
        echo $field->help;
        echo $helper->tag('/p');
    }

    if ($field->errors) {
        $errors = $helper->ul(['class' => 'errors']);
        $errors->items($field->errors);
        echo PHP_EOL;
        echo $errors;
        echo PHP_EOL;
    }

    echo $helper->tag('/div') . PHP_EOL;
    echo PHP_EOL;
}

The Versions

06/09 2017

dev-develop

dev-develop https://github.com/jnjxp/jnjxp.form

Describe collections of HTML form inputs

  Sources   Download

MIT

by jake johns

06/09 2017

dev-master

9999999-dev https://github.com/jnjxp/jnjxp.form

Describe collections of HTML form inputs

  Sources   Download

MIT

by jake johns

06/09 2017

0.3.0

0.3.0.0 https://github.com/jnjxp/jnjxp.form

Describe collections of HTML form inputs

  Sources   Download

MIT

by jake johns

19/11 2016

0.2.0

0.2.0.0 https://github.com/jnjxp/jnjxp.form

Describe collections of HTML form inputs

  Sources   Download

MIT

by jake johns

20/06 2016

0.1.0

0.1.0.0 https://github.com/jnjxp/jnjxp.form

Describe collections of HTML form inputs

  Sources   Download

MIT

by jake johns