2017 © Pedro Peláez
 

library form

Highly customizable forms in multiple formats

image

klapuch/form

Highly customizable forms in multiple formats

  • Wednesday, September 13, 2017
  • by klapuch
  • Repository
  • 1 Watchers
  • 0 Stars
  • 1,366 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 21 Versions
  • 0 % Grown

The README.md

Form

Build Status Build status Coverage Status, (*1)

Documentation

Installation

composer require klapuch/form, (*2)

Usage

Form

new Form\RawForm(
    [
        'method' => 'POST',
        'role' => 'form',
        'class' => 'form-horizontal',
        'action' => '/process.php',
        'name' => self::NAME,
    ],
    new Form\CsrfInput($this->csrf)
);

Select with options

new Form\Select(
    new Form\FakeAttributes(['name' => 'fruit']),
    new Form\Option(
        new Form\DependentAttributes(['value' => 'apple'], $this->storage, 'fruit'),
        'Apple',
        new Validation\OneOfRule(['apple', 'berry'])
    ),
    new Form\Option(
    new Form\DependentAttributes(['value' => 'berry'], $this->storage, 'fruit'),
    'Berry',
    new Validation\OneOfRule(['apple', 'berry'])
    )
);

Input with label

new Form\BoundControl(
    new Form\Input(
        new Form\StoredAttributes(
            [
                'type' => 'email',
                'name' => 'email',
                'class' => 'form-control',
                'required' => 'required',
            ],
            $this->storage
        ),
        new Constraint\EmailRule()
    ),
    new Form\LinkedLabel('Email', 'email')
);

The Versions