<commit_before># Formality (Laravel)

Form fields helper and guesser. Tries to detect the field type based on the name and the given config.

# Installation

Add the providers and alias from `laravelcollective/html` dependency (if you haven't already) as described [here](https://laravelcollective.com/docs/5.2/html)

# Usage

fields_config.php
```php
return [
    // Field Type (Should be a Type that exists)
    'password' => [],
    'text' => [
        'autodetect' => [
            'title',  
        ]
    ],
    'textarea' => [
        'autodetect' => [
            'body',  
        ],
        'hooks' => [
            // Youcan register hooks to modify the output
            'onOutput' => function($output) {
                return '<div>' . $output . '</div>'
            }
        ]
    ],
    'datetime' => [
        'regex' => [
            '/_at$/'
        ],
        // Inline input with automatic replacements
        'input' => '<input type="date" name="(:name)" value="(:value)" placeholder="(:label)">'
    ],
];
```

Wherever.php
```php

$fieldTypes = require "fields_config.php";

$fieldNames = [
    'title', // will generate a title Field
    'body', // will generate a textarea Field
    'created_at', // will generate a datetime Field
    'password', // will generate a password Field
];

$parser = new Mascame\Formality\Parser\Parser($fieldTypes);
$factory = new Mascame\Formality\Factory\Factory($parser, $fieldTypes, ['should-be-a-text-field']);

$fields = $factory->makeFields();<commit_msg>= fix typo<commit_after># Formality (Laravel)

Form fields helper and guesser. Tries to detect the field type based on the name and the given config.

# Installation

Add the providers and alias from `laravelcollective/html` dependency (if you haven't already) as described [here](https://laravelcollective.com/docs/5.2/html)

# Usage

fields_config.php
```php
return [
    // Field Type (Should be a Type that exists)
    'password' => [],
    'text' => [
        'autodetect' => [
            'title',  
        ]
    ],
    'textarea' => [
        'autodetect' => [
            'body',  
        ],
        'hooks' => [
            // Youcan register hooks to modify the output
            'onOutput' => function($output) {
                return '<div>' . $output . '</div>'
            }
        ]
    ],
    'datetime' => [
        'regex' => [
            '/_at$/'
        ],
        // Inline input with automatic replacements
        'input' => '<input type="date" name="(:name)" value="(:value)" placeholder="(:label)">'
    ],
];
```

Wherever.php
```php

$fieldTypes = require "fields_config.php";

$fieldNames = [
    'title', // will generate a text Field
    'body', // will generate a textarea Field
    'created_at', // will generate a datetime Field
    'password', // will generate a password Field
];

$parser = new Mascame\Formality\Parser\Parser($fieldTypes);
$factory = new Mascame\Formality\Factory\Factory($parser, $fieldTypes, ['should-be-a-text-field']);

$fields = $factory->makeFields();
{'fraction_non_alphanumeric': 0.15382081686429513, 'fraction_numerical': 0.0013175230566534915, 'mean_word_length': 2.400895856662934, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 31, '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': '996500', 'n_tokens_mistral': 917, 'n_tokens_neox': 896, 'n_words': 251}