PHPackages                             hypnokizer/formbuilder - 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. [Templating &amp; Views](/categories/templating)
4. /
5. hypnokizer/formbuilder

ActiveLibrary[Templating &amp; Views](/categories/templating)

hypnokizer/formbuilder
======================

Class to build HTML forms

v7.0.0(1mo ago)05MITPHPPHP &gt;=8.3.0

Since Jun 4Pushed 1mo agoCompare

[ Source](https://github.com/Hypnokizer/Formbuilder)[ Packagist](https://packagist.org/packages/hypnokizer/formbuilder)[ Docs](https://github.com/Hypnokizer/Formbuilder)[ RSS](/packages/hypnokizer-formbuilder/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependenciesVersions (2)Used By (0)

Formbuilder class
=================

[](#formbuilder-class)

This class quickly builds from HTML. It is tailored for Bootstrap 5, but can be adapted for use anywhere. Almost all form element types are supported.

Basic Use
---------

[](#basic-use)

Instantiate the object. The only parameter is optional and defines the type of form to be displayed.

```
$f = new form();
$f->formAttr('class', 'myFormClass');

```

If there is data which needs to be used to prepopulate the form, such as database results, it can be set using the `setEditData()` method.

```
$f->setEditData($databaseresults);

```

Once the form is defined, the form elements can be added in order. Every field must start with the `field()` method which outlines the type of element, the name, and the label. The `attr()` method can be used to add attributes when needed. For those form elements requiring choices or options, such as the `select` or `radio` elements, the `choices()` method can be called.

```
$f->field('text', 'fname', 'First Name')->attr('class', 'myClassName');
$f->field('select', 'title', 'Title')->choices($titles);

```

The `showForm()` method quickly displays the entire form. Alternatively, the `show()` method can be used to display each element individually. This allows for more complex form layouts.

Debugging
---------

[](#debugging)

There is one method used for debugging. It displays the entire object and its values.

```
$f->showObject();

```

Complete Example
----------------

[](#complete-example)

The example below shows the most basic usage of this class.

```
$genders = array('male' => 'Male', 'female' => 'Female');

$f = new formbuilder();
$f->formAttr('id', 'myFormID')->formAttr('class', 'myclassname');

$f->setEditData($databaseresults);

$f->field('text', 'fname', 'First Name');
$f->field('text', 'lname', 'Last Name');
$f->field('text', 'age', 'Age');
$f->field('select', 'gender', 'Gender')->choices($genders);
$f->field('textarea', 'comments', 'Comments')->attr('rows', 5);
$f->field('submit', 'submit', 'Submit')->attr('class', 'css-style');

$f->showForm();

```

###  Health Score

39

—

LowBetter than 84% of packages

Maintenance90

Actively maintained with recent releases

Popularity4

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity48

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

50d ago

### Community

Maintainers

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

---

Top Contributors

[![Hypnokizer](https://avatars.githubusercontent.com/u/279126957?v=4)](https://github.com/Hypnokizer "Hypnokizer (26 commits)")

### Embed Badge

![Health badge](/badges/hypnokizer-formbuilder/health.svg)

```
[![Health](https://phpackages.com/badges/hypnokizer-formbuilder/health.svg)](https://phpackages.com/packages/hypnokizer-formbuilder)
```

###  Alternatives

[limenius/react-bundle

Client and Server-side react rendering in a Symfony Bundle

3851.2M](/packages/limenius-react-bundle)[webkinder/sproutset

A Composer package for handling responsive images in Roots Bedrock + Sage + Blade projects.

282.2k](/packages/webkinder-sproutset)

PHPackages © 2026

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