PHPackages                             paperscissorsandglue/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. paperscissorsandglue/form-builder

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

paperscissorsandglue/form-builder
=================================

A flexible form builder for PHP applications

0.33(1y ago)0117MITPHPPHP ^8.2

Since Aug 29Pushed 1y ago1 watchersCompare

[ Source](https://github.com/paperscissors/FormBuilder)[ Packagist](https://packagist.org/packages/paperscissorsandglue/form-builder)[ RSS](/packages/paperscissorsandglue-form-builder/feed)WikiDiscussions main Synced yesterday

READMEChangelogDependencies (1)Versions (16)Used By (0)

FormBuilder
===========

[](#formbuilder)

FormBuilder is a flexible PHP library for creating and rendering HTML forms. It provides an intuitive API for defining form fields, setting attributes, and handling form submissions.

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

[](#installation)

You can install FormBuilder via Composer:

```
composer require paperscissorsandglue/formbuilder

Usage
Basic Usage
use PaperScissorsAndGlue\FormBuilder\FormBuilder;

$form = new FormBuilder();

$form->add('name', 'text', ['label' => 'Name'])
     ->add('email', 'text', ['label' => 'Email'])
     ->add('submit', 'submit', ['label' => 'Submit'])
     ->method('POST')
     ->url('/submit')
     ->class('my-form');

echo $form->render();

Field Types
FormBuilder supports the following field types:

text
textarea
checkbox
radio
select
number
hidden
submit

Adding Fields
Use the add method to add fields to your form:
$form->add('fieldName', 'fieldType', [
    'label' => 'Field Label',
    'attr' => ['class' => 'form-control'],
    // Other options...
]);

Field Options
Each field type supports various options:

label: The label for the field
attr: An array of HTML attributes for the field
placeholder: Placeholder text for text inputs
choices: An array of options for select, radio, and checkbox fields
empty_value: An initial empty option for select fields
wrapper: Wrap the field in a container (e.g., for Bootstrap)
label_attr: Attributes for the label element
errors: Configure error display for the field

Form Attributes
Set form attributes using method chaining:
$form->method('POST')
     ->url('/submit')
     ->class('my-form');

CSRF Protection
Add CSRF protection to your form:
$form->csrf('your_csrf_token_here');

Model Binding
Bind a model to pre-fill form values:
$user = new User(['name' => 'John Doe', 'email' => 'john@example.com']);
$form->model($user);

Embedded Forms
You can embed one form inside another:
$addressForm = new FormBuilder();
$addressForm->add('street', 'text', ['label' => 'Street'])
            ->add('city', 'text', ['label' => 'City']);

$mainForm = new FormBuilder();
$mainForm->add('name', 'text', ['label' => 'Name'])
         ->add('address', 'form', [
             'form' => $addressForm,
             'formOptions' => ['class' => 'embedded-form']
         ]);

Rendering
Render the entire form:
echo $form->render();

Or render individual fields:
echo $form->name;
echo $form->email;

Customization
FormBuilder is designed to be easily customizable. You can extend the FormBuilder class to add your own field types or modify existing ones.

Contributing
Contributions are welcome! Please feel free to submit a Pull Request.

License
This project is open-sourced software licensed under the MIT license.

This updated README.md file includes information about the new functionality you've added, such as:

1. Additional field types (number, hidden)
2. More detailed explanation of field options
3. Information about embedded forms
4. CSRF protection
5. Model binding
6. Rendering individual fields

The README now provides a comprehensive guide to using the FormBuilder class, covering all the main features and usage patterns.
```

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance40

Moderate activity, may be stable

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity50

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 ~11 days

Recently: every ~40 days

Total

15

Last Release

513d ago

PHP version history (2 changes)0.1PHP ^8.0

0.33PHP ^8.2

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/15576?v=4)[Tom Filepp](/maintainers/paperscissors)[@paperscissors](https://github.com/paperscissors)

---

Top Contributors

[![paperscissors](https://avatars.githubusercontent.com/u/15576?v=4)](https://github.com/paperscissors "paperscissors (15 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/paperscissorsandglue-form-builder/health.svg)

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

###  Alternatives

[acquia/drupal-recommended-settings

The composer plugin for adding drupal-recommended-settings for Acquia Cloud.

111.3M6](/packages/acquia-drupal-recommended-settings)[lightsuner/carbon-bundle

Provide Carbon datetime lib. as annotations param. converter (SensioFrameworkExtraBundle)

15125.5k](/packages/lightsuner-carbon-bundle)[ctsoft/laravel-pretty-pagination

Pretty pagination URLs for Laravel.

171.9k](/packages/ctsoft-laravel-pretty-pagination)

PHPackages © 2026

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