2017 © Pedro Peláez
 

library formz

A simple form libary for PHP, inspired by the form component from the PlayFramework

image

dennis84/formz

A simple form libary for PHP, inspired by the form component from the PlayFramework

  • Wednesday, March 12, 2014
  • by dennis84
  • Repository
  • 1 Watchers
  • 0 Stars
  • 41 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Formz

A simple form libary for PHP, inspired by the form component from the PlayFramework., (*1)

Build Status, (*2)

Example

This is a quick example to give you a taste of what formz does., (*3)

<?php

$builder = new \Formz\Builder();

$form = $builder->form([
    // Creates a text field that must not be blank.
    $builder->field('name')->nonEmptyText(),
    // Creates a numeric field.
    $builder->field('age')->integer(),
], function ($name, $age) {
    // This is the apply function. Use this function to convert the submitted
    // data to your domain objects.
    return new User($name, $age);
}, function (User $user) {
    // This is the unapply function. Use it to convert your domain models into
    // an associative array. This function is only needed if you want to fill a 
    // form with existing values.
    return [
        'name' => $user->getName(),
        'age' => $user->getAge(),
    ];
});

// Binds the $_POST data to the form.
$form->bind($_POST);

if ($form->isValid()) {
    // Get the applied data. In this example, this is the "User" object.
    $user = $form->getData();
}

More examples

Formz has a pretty comprehensive test coverage that demonstrates the whole bunch of functionality., (*4)

The Versions

12/03 2014

dev-master

9999999-dev http://github.com/dennis84/formz

A simple form libary for PHP, inspired by the form component from the PlayFramework

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dennis Dietrich

form