2017 © Pedro Peláez
 

library miniform

Minimalistic PHP forms library

image

pashist/miniform

Minimalistic PHP forms library

  • Saturday, February 13, 2016
  • by pashist
  • Repository
  • 1 Watchers
  • 0 Stars
  • 2 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

MiniForm

Minimalistic PHP forms library, (*1)

Basic usage

Creating form instance:
$form = new \MiniForm\Form();
$form->addInput(['name' => 'someName', 'type' => 'text']); //name is required
$form->addInput(['name' => 'someName2', 'type' => 'text', 'required' => true]);

or, (*2)

$form = new \MiniForm\Form([
    'fields' => [
        ['input', ['type' => 'text', 'name' => 'someName' ]],
        ['input', ['type' => 'text', 'name' => 'someName2', 'required' => true ]]
    ]
]);
Submit data to form:
$form->submit(['someName' => 'someValue']);

or, (*3)

$form->submit(); //same as $form->submit($_REQUEST); 
Validate form:
$form->validate(); // not neccessary
$form->isValid(); // true/false
$form->getErrors() // ['someName2' => ['this field is required']]
Display form:
<div>
   <?php echo $form->html() ?>
</div>

Or, (*4)

<div>
   <?php echo $form ?>
</div>

Or show each field separately, (*5)

<form>
  <div class="form-group">
    <label>Some Label</label>
    <?php echo $form->someName->html() ?> 
  </div>
  <div class="form-group">
      <label>Some Label 2</label>
      <?php echo $form->someName2 ?> 
    </div>
</form>

To be continued ;)

The Versions

13/02 2016

dev-master

9999999-dev

Minimalistic PHP forms library

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

by Avatar pashist