PHPackages                             pollen-solutions/form - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. pollen-solutions/form

ActiveLibrary

pollen-solutions/form
=====================

Pollen Solutions - Form Component - Generator and processor tools for PHP web application forms.

v1.0.2(4y ago)06MITPHPPHP ^7.4 || ^8.0

Since Aug 18Pushed 3y ago1 watchersCompare

[ Source](https://github.com/pollen-solutions/form)[ Packagist](https://packagist.org/packages/pollen-solutions/form)[ Docs](https://www.presstify.com/pollen-solutions/form/)[ RSS](/packages/pollen-solutions-form/feed)WikiDiscussions master Synced 5d ago

READMEChangelogDependencies (12)Versions (5)Used By (0)

Pollen Form Component
=====================

[](#pollen-form-component)

[![Latest Stable Version](https://camo.githubusercontent.com/b519d46cb5ef1a173dbcb149f9486bf311c6048d3e9f9768c431286f4cb501b3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f706f6c6c656e2d736f6c7574696f6e732f666f726d2e7376673f7374796c653d666f722d7468652d6261646765)](https://packagist.org/packages/pollen-solutions/form)[![MIT Licensed](https://camo.githubusercontent.com/daa52099573be5a50c320c4387496400f2f722e49f86a42db8d5778130d3582d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d677265656e3f7374796c653d666f722d7468652d6261646765)](LICENSE.md)[![PHP Supported Versions](https://camo.githubusercontent.com/d9d71d0b69072c51e1ff7adfdb6270f896f75787500ce6437120e23727c081d1/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d2533453d372e342d3838393242463f7374796c653d666f722d7468652d6261646765266c6f676f3d706870)](https://www.php.net/supported-versions.php)

Pollen Solutions **Form** Component provides generator and processor tools for PHP web application forms.

Installation
------------

[](#installation)

```
composer require pollen-solutions/form
```

Basic Usage
-----------

[](#basic-usage)

### Parameters definition

[](#parameters-definition)

```
use Laminas\HttpHandlerRunner\Emitter\SapiEmitter;
use Pollen\Form\FormManager;

$forms = new FormManager();

$form = $forms->buildForm(
    [
        /**
         * Alias (Recommended)
         * {@internal Alias is used for generate default HTML tag class, title.
         * By default an SHA-1 string is generated, it is not human readable.}
         * @var string
         */
        'alias'  => 'auth',
        /**
         * Form fields
         * @see Configuration/Field] below for more details
         * @var array
         */
        'fields' => [
            'login' => [
                'type' => 'text',
            ],
            'pass'  => [
                'type' => 'password',
            ],
        ],
    ]
)->get();

if ($response = $form->handle()->proceed()) {
    (new SapiEmitter())->emit($response->psr());
    exit;
}

echo $form;
```

### Form instance definition

[](#form-instance-definition)

```
use Laminas\HttpHandlerRunner\Emitter\SapiEmitter;
use Pollen\Form\Form;
use Pollen\Form\FormManager;

$forms = new FormManager();

$form = $forms->buildForm(new class extends Form {
    protected ?string $alias = 'auth';

    public function defaultParams(): array
    {
        return array_merge(parent::defaultParams(), [
            'fields' => [
                'login' => [
                    'type' => 'text',
                ],
                'pass'  => [
                    'type' => 'password',
                ],
            ],
        ]);
    }
})->get();

if ($response = $form->handle()->proceed()) {
    (new SapiEmitter())->emit($response->psr());
    exit;
}

echo $form;
```

### Dependency injection service definition

[](#dependency-injection-service-definition)

```
use Laminas\HttpHandlerRunner\Emitter\SapiEmitter;
use Pollen\Container\Container;
use Pollen\Form\Form;
use Pollen\Form\FormManager;

$container = new Container();

$forms = new FormManager([], $container);

class AuthForm extends Form
{
    /**
     * Alias identifier.
     * @var string|null
     */
    protected ?string $alias = null;

    /**
     * @inheritDoc
     */
    public function defaultParams(): array
    {
        return array_merge(parent::defaultParams(), [
            'fields' => [
                'login' => [
                    'type' => 'text',
                ],
                'pass'  => [
                    'type' => 'password',
                ],
            ],
        ]);
    }
}

$container->add(AuthForm::class);

$form = $forms->buildForm(AuthForm::class)->get();

if ($response = $form->handle()->proceed()) {
    (new SapiEmitter())->emit($response->psr());
    exit;
}

echo $form;
```

Configuration
-------------

[](#configuration)

### Form

[](#form)

```
[
    /**
     * Action attribute in the form HTML tag.
     * @var string $action
     */
    'action'   => '',
    /**
     * List of enabled add-ons|List of enabled add-ons and their parameters.
     * @var string[]|array $addons
     */
    'addons'   => [],
    /**
     * HTML content displayed after the form close tag.
     * @var string $after
     */
    'after'    => '',
    /**
     * List of the HTML attributes for the form tag.
     * @var array $attrs.
     */
    'attrs'    => [],
    /**
     * HTML content displayed before the form open tag.
     * @var string $before
     */
    'before'   => '',
    /**
     * List of enabled buttons|List of enabled buttons and their parameters.
     * @var array $buttons Liste des attributs des boutons actifs.
     */
    'buttons'  => [],
    /**
     * Enctype attribute in the form HTML tag.
     * @var string $enctype
     */
    'enctype'  => '',
    /**
     * List of observed and dispatched events.
     * @var array $events
     */
    'events'   => [],
    /**
     * List of field parameters.
     * @var array $fields
     */
    'fields'   => [],
    /**
     * HTTP request method of form submission.
     * @var string $method
     */
    'method'   => 'post',
    /**
     * List of option parameters.
     * @var array $options
     */
    'options'  => [],
    /**
     * List of supported features.
     * @var string[] $supports
     */
    'supports' => ['session'],
    /**
     * Form title.
     * @var string $title
     */
    'title'    => $this->getAlias(),
    /**
     * CSRF token activation (recommended).
     * @var bool
     */
    'token'    => true,
    /**
     * List of parameters of the template view|View instance.
     * @var array|ViewInterface $view
     */
    'view'   => [],
    /**
     * List of HTML form wrapper parameters.
     * @var array $wrapper
     */
    'wrapper'  => []
];
```

### Field

[](#field)

```
[
    /**
     * List of addon parameters.
     * @var array|array $addons
     */
    'addons'      => [],
    /**
     * HTML content displayed after the field.
     * @var string $after
     */
    'after'       => '',
    /**
     * List of the HTML tag attributes.
     * @var array $attrs
     */
    'attrs'       => [],
    /**
     * HTML content displayed before the field.
     * @var string $before
     */
    'before'      => '',
    /**
     * List of choices for field with multiple value.
     * @var array $choices
     */
    'choices'     => [],
    /**
     * List of extra parameters.
     * @var array $extras
     */
    'extras'      => [],
    /**
     * Alias of the related group.
     * @var string|null $group
     */
    'group'       => null,
    /**
     * Field label.
     * {@internal true for default|false to hide|array of custom parameters}.
     * @var bool|string|array $label
     */
    'label'       => true,
    /**
     * Name HTML tag attribute in the handle HTTP request.
     * @var string $name Indice de qualification de la variable de requête.
     */
    'name'        => $this->getSlug(),
    /**
     * Display position.
     * @var int $position
     */
    'position'    => 0,
    /**
     * Required field parameters.
     * ---------------------------------------------------------------------------------------------------------
     * {@internal true for default parameters|false to disabling|array of custom parameters.
     * @var bool|string|array $required {
     *
     * HTML tag.
     * {@internal true for default parameters|false to hide|array of custom parameters based.}
     * @see \Pollen\Field\Drivers\RequiredDriver
     * @var bool|string|array $tagged
     *
     * Enable required validation.
     * @var bool $check
     *
     * Value of none value. empty string by default.
     * @var mixed $value_none
     *
     * Validation function name|validation callable.
     * @var string|callable $call
     *
     * List of arguments passed in the validation handle.
     * @var array $args
     *
     * Notification message if validation failed.
     * @type string $message
     * }
     */
    'required'    => false,
    /**
     * List of supported features.
     * @var array $supports label|wrapper|request|tabindex|transport.
     */
    'supports'    => [],
    /**
     * Title.
     * @var string|null $title
     */
    'title'       => null,
    /**
     * Disable the persistent value in the submission HTTP response.
     * {@internal if null, use the support feature value.}
     * @var bool|null $transport
     */
    'transport'   => null,
    /**
     * Field type.
     * @var string $type
     */
    'type'        => 'html',
    /**
     * List of validation tests.
     * ---------------------------------------------------------------------------------------------------------
     * @var string[]|array[][] $validations {
     *
     * Validation function name|validation callable.
     * @var string|callable $call
     *
     * List of arguments passed in the validation handle.
     * @var  array $args
     *
     * Notification message if validation failed.
     * @type string $message
     * }
     */
    'validations' => [],
    /**
     * Current value.
     * @var mixed $value
     */
    'value'       => null,
    /**
     * Field HTML Wrapper.
     * {@internal true for default parameters|false for hide|array of custom parameters.}
     * @var bool|string|array $wrapper
     */
    'wrapper'     => null
];
```

Stepwise process decomposition
------------------------------

[](#stepwise-process-decomposition)

```
use Laminas\HttpHandlerRunner\Emitter\SapiEmitter;
use Pollen\Form\FormManager;
use Pollen\Form\Exception\FieldMissingException;
use Pollen\Form\Exception\FieldValidateException;
use Pollen\Http\Request;

// Step 1 : Instantiate the Form Manager.
$forms = new FormManager();

// Step 2 : Register a Form.
$forms->registerForm(
    'auth',
    [
        'fields' => [
            'login' => [
                'type'     => 'text',
                'required' => true,
            ],
            'pass'  => [
                'type'        => 'password',
                'required'    => true,
                'validations' => 'password',
            ],
        ],
    ]
);

// Step 3 : Get and Boot the Form. After booting the form becomes immutable.
$form = $forms->get('auth')->boot();

// Step 4 : Form validation.
$request = Request::createFromGlobals();
$form->setHandleRequest($request);
$handle = $form->handle();

if ($form->isSubmitted()) {
    try {
        $field = $form->formField('login');
        $field->validate($handle->datas('login'));
    } catch (FieldMissingException $e) {
        $form->error($e->getMessage());
    } catch (FieldValidateException $e) {
        $form->error('Please enter a username.', ['field' => 'login']);
    }

    try {
        $field = $form->formField('pass');
        $field->validate($handle->datas('pass'));
    } catch (FieldMissingException $e) {
        $form->error($e->getMessage());
    } catch (FieldValidateException $e) {
        if ($e->isRequired()) {
            $form->error('Please enter a password.', ['field' => 'pass']);
        } elseif ($e->hasFlag('password')) {
            $form->error('Password format is invalid.', ['field' => 'pass']);
        }
    }

    if (!$form->handle()->isValidated()) {
        $form->handle()->fail();
    } else {
        $form->handle()->success();
    }

    /**
     * Redirect response (optionnal but best pratice).
     * {@internal Send form handle redirect response ensure that the form is always display through a GET HTTP method.
     * All request data is then catched and dispatched by the session processor.}
     */
    $response = $form->handle()->redirectResponse();

    if ($form->isSuccessful()) {
        (new SapiEmitter())->emit($response->psr());
    } else {
        (new SapiEmitter())->emit($response->psr());
    }
    exit;
    /** End of redirect response */
}

// Step 5 : Form render
echo $form;
```

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

4

Last Release

1731d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/c1d9488545d6b446f8df86ec373a070e7fed1166fc47e1324d963e46d3d838d3?d=identicon)[presstify](/maintainers/presstify)

---

Top Contributors

[![jordy-manner](https://avatars.githubusercontent.com/u/733356?v=4)](https://github.com/jordy-manner "jordy-manner (6 commits)")

---

Tags

componentformpollen-solutions

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/pollen-solutions-form/health.svg)

```
[![Health](https://phpackages.com/badges/pollen-solutions-form/health.svg)](https://phpackages.com/packages/pollen-solutions-form)
```

###  Alternatives

[atk4/ui

Agile UI - Web Component Framework written in PHP

454540.1k32](/packages/atk4-ui)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
