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

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

typicms/form
============

A basic framework agnostic form building package with a few extra niceties like remembering old input and retrieving error messages.

4.0.0(1mo ago)456.1k↑26.3%22MITPHPPHP ^8.2CI passing

Since May 9Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/typicms/form)[ Packagist](https://packagist.org/packages/typicms/form)[ GitHub Sponsors](https://github.com/typicms)[ RSS](/packages/typicms-form/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (7)Dependencies (13)Versions (9)Used By (2)

Form
====

[](#form)

[![Latest Version on Packagist](https://camo.githubusercontent.com/da686901c52907b52e87250380f2548dd0439b1146f93064e3c78d54e75bc0cc/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f74797069636d732f666f726d2e737667)](https://packagist.org/packages/typicms/form)[![tests](https://github.com/typicms/form/actions/workflows/tests.yml/badge.svg?branch=main)](https://github.com/typicms/form/actions/workflows/tests.yml)[![Rector](https://github.com/typicms/form/actions/workflows/rector.yml/badge.svg?branch=main)](https://github.com/typicms/form/actions/workflows/rector.yml)[![Pint](https://github.com/typicms/form/actions/workflows/pint.yml/badge.svg?branch=main)](https://github.com/typicms/form/actions/workflows/pint.yml)

Build HTML form with an intuitive syntax.

This package was originally created by [Adam Wathan](https://github.com/adamwathan).

- [Installation](#installation)
- [Basic Usage](#basic-usage)
- [Remembering Old Input](#remembering-old-input)
- [Error Messages](#error-messages)
- [CSRF Protection](#csrf-protection)
- [Data Binding](#data-binding)

[](#installation)

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

[](#installation)

You can install this package via Composer by running this command in your terminal in the root of your project:

```
composer require typicms/form
```

### Laravel

[](#laravel)

> This package works great as a replacement Form Builder that was removed in Laravel 5. The API is different but all of the features are there.

If you are using Laravel 4 or 5, you can register the FormServiceProvider to automatically gain access to the Old Input and Error Message functionality.

To do so, just update the `providers` array in your `config/app.php`:

```
'providers' => [
        //...
        'TypiCMS\Form\FormServiceProvider'
    ],
```

You can also choose to use the Facade by adding an alias in `config/app.php`:

```
'aliases' => [
        //...
        'Form' => 'TypiCMS\Form\Facades\Form',
    ],
```

> Note that in Laravel 4, there is already a Form facade for the built-in Form Builder. If you want to use both, use a different alias. If you'd just like to use this one, remove the Form alias that points to the Illuminate component.

[](#basic-usage)

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

[](#basic-usage)

- [Getting Started](#getting-started)
- [Opening a Form](#opening-a-form)
- [Text and Password Fields](#text-and-password-fields)
- [Textareas](#textareas)
- [Checkboxes and Radio Buttons](#checkboxes-and-radio-buttons)
- [Selects](#selects)
- [Buttons](#buttons)
- [Hidden Inputs](#hidden-inputs)
- [Labels](#labels)
- [Setting Attributes](#setting-attributes)

[](#getting-started)

### Getting Started

[](#getting-started)

First, instantiate a FormBuilder...

```
$builder = new TypiCMS\Form\FormBuilder;
```

Next, use the FormBuilder to build an element. For example:

```
//
