PHPackages                             sinevia/php-library-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. [Utility &amp; Helpers](/categories/utility)
4. /
5. sinevia/php-library-form

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

sinevia/php-library-form
========================

PHP Library Form

v0.1.0(6y ago)0601proprietaryPHP

Since Oct 23Pushed 6y ago2 watchersCompare

[ Source](https://github.com/Sinevia/php-library-form)[ Packagist](https://packagist.org/packages/sinevia/php-library-form)[ Docs](http://github.com/sinevia/php-library-form)[ RSS](/packages/sinevia-php-library-form/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (4)Dependencies (3)Versions (5)Used By (0)

[![Gitpod Ready-to-Code](https://camo.githubusercontent.com/ec0084907bd5b3576af415a1e46cae636fbfa04da6bf9db6296eae3057a189f0/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f476974706f642d52656164792d2d746f2d2d436f64652d626c75653f6c6f676f3d676974706f64)](https://gitpod.io/#https://github.com/Sinevia/php-library-form)

Form
====

[](#form)

A form helper

Building Forms
--------------

[](#building-forms)

```
$form = \Sinevia\Form::build($fields)->toHtml();
```

Validating Forms
----------------

[](#validating-forms)

```
$isValidOrErrors = \Sinevia\Form::validate($fields);
```

Fields
------

[](#fields)

The field is an associative array consisting of the following key-value pairs:

- type - one of text, textarea, select, hidden, html
- name - name of the input field as seen in the request
- label - publicly visible name
- width - width of the field - min 1, max 12
- rule - rules for the field, used when validating
- value - value of the field
- options - array of options (used by the select type)
- html - raw HTML to be displayed as-is (used by the html type)

Example:

```
[
    'type' => 'text',
    'name' => 'FirstName',
    'label' => 'First name',
    'width' => 6,
    'rule' => 'required',
    'value' => $value,
]
```

Full Example
------------

[](#full-example)

```
function formProfileFields($user) {
    $countriesList = \App\Models\Countries\Country::all()->pluck('Name', 'Iso2')->toArray();
    asort($countriesList);
    $countries = ['' => '- country -'] + $countriesList;

    $daysRange = range(1, 12);
    $days = [
        '' => '- day -'
    ];
    foreach ($daysRange as $day) {
        $days[$day] = $day;
    }

    $monthsRange = range(1, 12);
    $months = [
        '' => '- month -'
    ];
    foreach ($monthsRange as $month) {
        $months[$month] = $month;
    }

    $yearsRange = range(1940, 2014);
    $years = [
        '' => '- year -'
    ];
    foreach ($yearsRange as $year) {
        $years[$year] = $year;
    }

    $fields = [
        [
            'type' => 'html',
            'html' => '.btn-success { width:100%; padding:10px;}',
        ],
        [
            'type' => 'html',
            'html' => 'Profile',
        ],
        [
            'type' => 'text',
            'name' => 'FirstName',
            'label' => 'First name',
            'width' => 6,
            'rule' => 'required',
            'value' => $user->FirstName,
        ],
        [
            'type' => 'text',
            'name' => 'LastName',
            'label' => 'last name',
            'width' => 6,
            'rule' => 'required',
            'value' => $user->LastName,
        ],
        [
            'type' => 'select',
            'name' => 'DayOfBirth',
            'options' => $days,
            'label' => 'Day of Birth',
            'width' => 2,
            'rule' => 'required',
            'value' => is_null($user->Birthday) ? '' : date('d', strtotime($user->Birthday)),
        ],
        [
            'type' => 'select',
            'name' => 'MonthOfBirth',
            'options' => $months,
            'label' => 'Month of Birth',
            'width' => 2,
            'rule' => 'required',
            'value' => is_null($user->Birthday) ? '' : date('m', strtotime($user->Birthday)),
        ],
        [
            'type' => 'select',
            'name' => 'YearOfBirth',
            'options' => $years,
            'label' => 'Year of Birth',
            'width' => 2,
            'rule' => 'required',
            'value' => is_null($user->Birthday) ? '' : date('Y', strtotime($user->Birthday)),
        ],
        [
            'type' => 'html',
            'html' => 'Address',
        ],
        [
            'type' => 'select',
            'name' => 'Country',
            'label' => 'Country',
            'options' => $countries,
            'width' => 6,
            'rule' => 'required',
            'value' => $user->Country,
        ],
        [
            'type' => 'text',
            'name' => 'City',
            'label' => 'City',
            'rule' => 'required',
            'width' => 6,
            'value' => $user->City,
        ],
        [
            'type' => 'text',
            'name' => 'AddressLine1',
            'label' => 'Address Line 1',
            'rule' => 'required',
            'width' => 6,
            'value' => $user->Address1,
        ],
        [
            'type' => 'text',
            'name' => 'AddressLine2',
            'label' => 'Address Line 2 (optional)',
            'width' => 6,
            'value' => $user->Address2,
        ],
        [
            'type' => 'text',
            'name' => 'Province',
            'label' => 'Province / State / County',
            'rule' => 'required',
            'width' => 6,
            'value' => $user->Province,
        ],
        [
            'type' => 'text',
            'name' => 'Postcode',
            'label' => 'Postcode / Zip',
            'rule' => 'required',
            'width' => 6,
            'value' => $user->Postcode,
        ],
        [
            'type' => 'hidden',
            'name' => 'UserId',
            'label' => 'UserId',
            'rule' => 'required',
            'width' => 6,
            'value' => $user->Id,
        ],
    ];

    return $fields;
}

function formProfile($user) {
    return \Sinevia\Form::build($this->formProfileFields($user))->toHtml();
}

$isValidOrErrorArray = \Sinevia\Form::validate($this->formProfileFields($user));

if(is_array($isValidOrErrorArray)){
    // Validation failed, show errors
} else {
    // Validation was successful
}
```

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 94.7% 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 ~169 days

Total

4

Last Release

2254d ago

### Community

Maintainers

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

---

Top Contributors

[![Sinevia](https://avatars.githubusercontent.com/u/3450815?v=4)](https://github.com/Sinevia "Sinevia (18 commits)")[![lesichkovm](https://avatars.githubusercontent.com/u/7744963?v=4)](https://github.com/lesichkovm "lesichkovm (1 commits)")

---

Tags

phplibraryformsinevia

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/sinevia-php-library-form/health.svg)

```
[![Health](https://phpackages.com/badges/sinevia-php-library-form/health.svg)](https://phpackages.com/packages/sinevia-php-library-form)
```

PHPackages © 2026

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