PHPackages                             jayrchamp/simple-php-form-builder - 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. jayrchamp/simple-php-form-builder

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

jayrchamp/simple-php-form-builder
=================================

Yet another php form builder

v1.0.0(7y ago)214MITPHPPHP &gt;=5.4

Since Oct 3Pushed 7y agoCompare

[ Source](https://github.com/jayrchamp/simple-php-form-builder)[ Packagist](https://packagist.org/packages/jayrchamp/simple-php-form-builder)[ Docs](https://github.com/champjr/simple-php-form-builder)[ RSS](/packages/jayrchamp-simple-php-form-builder/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependenciesVersions (2)Used By (0)

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

[](#installation)

```
composer require jayrchamp/simple-php-form-builder
```

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

[](#basic-usage)

- [Getting Started](#getting-started)
    - [\#1 Instantiate the class](#instantiate-the-class)
    - [\#2 Add the required methods to the form object](#pass-the-required-attributes-to-the-form-object)
    - [\#3 Add form fields](#add-form-fields)
    - [\#4 Add a submit field](#add-a-submit-field)
    - [\#5 Close the form](#close-the-form)
- [More examples](#more-examples)

Getting Started
---------------

[](#getting-started)

### 1) Instantiate the class

[](#1-instantiate-the-class)

```
$form = new SimplePhpFormBuilder\Form();
```

### 2) Add the required methods (attribute) to the form object and open the form for fields

[](#2-add-the-required-methods-attribute-to-the-form-object-and-open-the-form-for-fields)

```
$form->action('/page/submit.php')->open();
```

#### Methods ( attributes )

[](#methods--attributes-)

- `action`

    - The action to be performed when the form is submitted.
    - *(string) (Required)*
- `method`

    - Accepts `GET`, `POST`.
    - *(string) (Optional) (Default `POST`)*
- `enctype`

    - Accepts `multipart/form-data`, `application/x-www-form-urlencoded`.
    - *(string) (Optional) (Default `multipart/form-data`)*
- `id`

    - Form's id attribute.
    - *(string) (Optional)*
- `class`

    - Form's classes as an array or string.
    - *(array | string ) (Optional)*
- `attr`

    - A key-value pair array of custom attributes with their associated value.
    - Or a string of a single attribute
    - *(array | string) (Optional) (Default `[]`)*

#### Action methods

[](#action-methods)

- `open`
    - Creates the form and gets it ready to receive field inputs.
    - Needs to be the last method added on the form object.
    - *(void) (Required)*

#### Complete example ( form's instantiation )

[](#complete-example--forms-instantiation--)

```
$form->id('form_id')
     ->action('/page/submit.php')
     ->method('POST')
     ->class('form_class1')->class(['form_class2', 'form_class3'])
     ->attr(['data-form' => 'form-data'])
     ->enctype('multipart/form-data')
     ->open();
```

### 3) Add form fields

[](#3-add-form-fields)

```
$form->field( string $type )->label( string $label )->build();
```

#### Methods ( attributes )

[](#methods--attributes--1)

- `field`

    - Field's type.
    - *(string) (Required)*
- `label`

    - Field's label
    - *(string) (Required)*
- `name`

    - Field's name attribute.
    - If not set, label will be slugified and added as field name attribute.
    - If you set it, it will automatically be slugified for you. Not need to add underscore, etc.
    - It will keep the square brackets, if you need an array.
    - *(string) (Optional) (Default `Slugified label`)*
- `value`

    - Field's value attribute
    - *(string) (Optional) (Default `''`)*
- `id`

    - Form's id attribute.
    - *(string) (Optional)*
- `class`

    - Form's classes as an array or string.
    - *(array | string ) (Optional)*
- `placeholder`

    - Field's placeholder
    - *(string) (Optional) (Default `''`)*
- `attr`

    - A key-value pair array of custom attributes with their associated value.
    - Or a string of a single attribute
    - *(array) (Optional) (Default `[]`)*

#### Action methods

[](#action-methods-1)

- `build`
    - Creates the field.
    - Needs to be the last method added on the field object.
    - *(void) (Required)*

#### Complete example ( Creation of a form field )

[](#complete-example--creation-of-a-form-field-)

```
$form->field( 'text' )
     ->label('What is your name?')
     ->name('name')
     ->placeholder('ie.: John Doe')
     ->id('text_id')
     ->class('text_class1')->class(['text_class2', 'text_class3'])
     ->attr(['data-text' => 'text-data'])
     ->attr('required')
     ->build();
```

### 4) Add a submit field

[](#4-add-a-submit-field)

```
$form->field('submit')->value('Send')->build();
```

#### Methods ( attributes )

[](#methods--attributes--2)

- `field`

    - Field's type.
    - *(string) (Required)*
- `label`

    - Field's label
    - *(string) (Optional) (work but useless)*
- `value`

    - Field's value attribute
    - *(string) (Optional) (Default `''`)*
- `id`

    - Form's id attribute.
    - *(string) (Optional)*
- `class`

    - Form's classes as an array or string.
    - *(array | string ) (Optional)*
- `attr`

    - Either a key-value pair array of custom attributes with their associated value.
    - or a string for a single attribute without value
    - *(array) (Optional) (Default `[]`)*

#### Action methods

[](#action-methods-2)

- `build`
    - Creates the field.
    - Needs to be the last method added on the field object.
    - *(void) (Required)*

### 5) Close the form

[](#5-close-the-form)

```
$form->close();
```

---

More examples
-------------

[](#more-examples)

### `select` form field

[](#select-form-field)

```
$form->field('select')
     ->label('Where do you want to go?')
     ->placeholder('Select')
     ->addOption('To the beach')
     ->addOption('Las vegas')
     ->addOption('Planet Mars')
     ->build();
```

### `checkbox` form field

[](#checkbox-form-field)

```
$form->field('checkbox')->label('Banana')->name('Favorite Fruits[]')->build();
$form->field('checkbox')->label('Apple')->name('Favorite Fruits[]')->build();
$form->field('checkbox')->label('Kiwi')->name('Favorite Fruits[]')->build();
```

### `radio` form field

[](#radio-form-field)

```
$form->field('radio')->label('Canada')->name('Favorite_country')->build();
$form->field('radio')->label('USA')->name('Favorite_country')->build();
$form->field('radio')->label('China')->name('Favorite_country')->build();
```

### `hidden` form field

[](#hidden-form-field)

```
$form->field('hidden')->name('my hidden field')->value('done')->build();
```

#### Methods ( attributes )

[](#methods--attributes--3)

- `field`

    - Field's type.
    - *(string) (Required)*
- `name`

    - Field's name. **Is Required since no label will be slugified**.
    - *(string) (Optional)*
- `value`

    - Field's value. **Not required but would be brian to add it**.
    - *(string) (Optional) (Default `''`)*
- `id`

    - Form's id attribute.
    - *(string) (Optional)*
- `class`

    - Form's classes as an array or string.
    - *(array | string ) (Optional)*
- `attr`

    - Either a key-value pair array of custom attributes with their associated value.
    - or a string for a single attribute without value
    - *(array) (Optional) (Default `[]`)*
- `label`

    - Field's label. **Work but useless**.
    - *(string) (Optional)*

#### Action methods

[](#action-methods-3)

- `build`
    - Creates the field.
    - Needs to be the last method added on the field object.
    - *(void) (Required)*

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity56

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

Unknown

Total

1

Last Release

2781d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/39443962?v=4)[jayrchamp](/maintainers/jayrchamp)[@jayrchamp](https://github.com/jayrchamp)

---

Top Contributors

[![jayrchamp](https://avatars.githubusercontent.com/u/39443962?v=4)](https://github.com/jayrchamp "jayrchamp (1 commits)")

---

Tags

phpbuilderform

### Embed Badge

![Health badge](/badges/jayrchamp-simple-php-form-builder/health.svg)

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

###  Alternatives

[kris/laravel-form-builder

Laravel form builder - symfony like

1.7k2.2M45](/packages/kris-laravel-form-builder)[gherkins/regexpbuilderphp

PHP port of thebinarysearchtree/regexpbuilderjs

1.4k163.0k1](/packages/gherkins-regexpbuilderphp)[godbout/dash-docset-builder

Dash (LOVE) Docset Builder in PHP (LOVE).

1253.5k](/packages/godbout-dash-docset-builder)[laraform/laraform-laravel

Laraform Community Edition (Laravel)

1537.0k](/packages/laraform-laraform-laravel)

PHPackages © 2026

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