<commit_before>Eloq [![Build Status](https://secure.travis-ci.org/Pixel418/Eloq.png)](http://travis-ci.org/Pixel418/Eloq)
======

Eloq is a pretty lib to handle form treatment.<br>
It's allow you to separate form definitions and form treatments.

1. [Let's code](#lets-code)
2. [How to Install](#how-to-install)
3. [How to Contribute](#how-to-contribute)
4. [Author & Community](#author--community)



Let's code
--------

```php
// Let's try and define a signup form
$signUp = (new Form)
    // Just add a first input
    ->addInput('email')
        // We can use predefined filters
        ->addInputFilter('email', 'required')
        // And PHP filters
        ->addInputFilter('email', FILTER_SANITIZE_EMAIL)
        // And your own specific filters
        ->addInputFilter('email', 'unique_email', function($email){
            return get_user_by_email($email) === NULL;
        })
    // You can prefer use the shorthand syntax
    ->addInput('password', '<PASSWORD>');

// We can access to the form state
if ( $signUp->isValid() ) {
    $email = $signUp->email;
    $password = $signUp->password;
    // Here we should create a new user ;)
} else {
		// We can access to each input state
    if ($signUp->isInputValid('email')) {
        // And focus to make great error message
        switch ($signUp->getInputError('email')) {
            case 'required':
                echo 'This field is required';
                break;
            case 'validate_email':
                echo 'This field must be a valid email';
                break;
            case 'unique':
                echo 'There is already a user with this email';
                break;
				}
    }
}
```

[&uarr; top](#readme)



How to Install
--------

If you don't have composer, you have to [install it](http://getcomposer.org/doc/01-basic-usage.md#installation).  

Add or complete the composer.json file at the root of your project, like this :<commit_msg>Simplify the README example<commit_after>Eloq [![Build Status](https://secure.travis-ci.org/Pixel418/Eloq.png)](http://travis-ci.org/Pixel418/Eloq)
======

Eloq is a pretty lib to handle form treatment.<br>
It's allow you to separate form definitions and form treatments.

1. [Let's code](#lets-code)
2. [How to Install](#how-to-install)
3. [How to Contribute](#how-to-contribute)
4. [Author & Community](#author--community)



Let's code
--------

```php
// Login form definition
$loginForm = (new Form)
    ->addInput('email', 'required|email')
    ->addInput('password', '<PASSWORD>');

// Treatment
if ($loginForm->isValid()) {
    $email = $signUp->email;
    $password = $loginForm->password;
    // Here we should log the user ;)
}
```
```html
<?php if (!$loginForm->isValid('email')): ?>
	<div class="alert-error"><?= $loginForm->getInputErrorMessage('email') ?></div>
<?php endif; ?>
<input type="text" name="email" value="<?= $loginForm->email ?>" />

<?php if (!$loginForm->isValid('password')): ?>
	<div class="alert-error"><?= $loginForm->getInputErrorMessage('password') ?></div>
<?php endif; ?>
<input type="password" name="email" value="" />
```

[&uarr; top](#readme)



How to Install
--------

If you don't have composer, you have to [install it](http://getcomposer.org/doc/01-basic-usage.md#installation).  

Add or complete the composer.json file at the root of your project, like this :
{'fraction_non_alphanumeric': 0.16950164130110415, 'fraction_numerical': 0.007162041181736795, 'mean_word_length': 3.033694344163658, 'pattern_counts': {'":': 0, '<': 20, '<?xml version=': 0, '>': 40, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6826516', 'n_tokens_mistral': 1081, 'n_tokens_neox': 1025, 'n_words': 308}