PHPackages                             laravie/html - 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. laravie/html

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

laravie/html
============

HTML and Form Builders for the Laravel Framework

v7.3.0(4y ago)36184.6k↓43.5%9[2 issues](https://github.com/laravie/html/issues)4MITPHPPHP ^7.2 || ^8.0

Since Nov 2Pushed 4y ago1 watchersCompare

[ Source](https://github.com/laravie/html)[ Packagist](https://packagist.org/packages/laravie/html)[ Docs](https://github.com/laravie/html)[ Fund](https://paypal.me/crynobone)[ Fund](https://liberapay.com/crynobone)[ RSS](/packages/laravie-html/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (7)Versions (46)Used By (4)

Forms &amp; HTML
================

[](#forms--html)

[![tests](https://github.com/laravie/html/workflows/tests/badge.svg?branch=7.x)](https://github.com/laravie/html/actions?query=workflow%3Atests+branch%3A7.x)[![Total Downloads](https://camo.githubusercontent.com/549df25fe5ba1b521f97493033a100582721fe1854b6f7596e8d2af2c8ae31cc/68747470733a2f2f706f7365722e707567782e6f72672f6c6172617669652f68746d6c2f646f776e6c6f616473)](https://packagist.org/packages/laravie/html)[![Latest Stable Version](https://camo.githubusercontent.com/fa058ffd6024a4cfdcb5ac3ded7abdd8321892d4a3e653bc07b61be4b29d1250/68747470733a2f2f706f7365722e707567782e6f72672f6c6172617669652f68746d6c2f762f737461626c652e737667)](https://packagist.org/packages/laravie/html)[![Latest Unstable Version](https://camo.githubusercontent.com/3829839c73ac18d9144a50058e503d35df002c22d932b3bdd660d8a0283049d2/68747470733a2f2f706f7365722e707567782e6f72672f6c6172617669652f68746d6c2f762f756e737461626c652e737667)](https://packagist.org/packages/laravie/html)[![License](https://camo.githubusercontent.com/5451d78a82051826642579084b73eadec1ab59f751e09d73229173672ca81734/68747470733a2f2f706f7365722e707567782e6f72672f6c6172617669652f68746d6c2f6c6963656e73652e737667)](https://packagist.org/packages/laravie/html)

- [Installation](#installation)
- [Opening A Form](#opening-a-form)
- [CSRF Protection](#csrf-protection)
- [Form Model Binding](#form-model-binding)
- [Form Model Accessors](#form-model-accessors)
- [Labels](#labels)
- [Text, Text Area, Password &amp; Hidden Fields](#text)
- [Checkboxes and Radio Buttons](#checkboxes-and-radio-buttons)
- [File Input](#file-input)
- [Number Input](#number)
- [Date Input](#date)
- [Drop-Down Lists](#drop-down-lists)
- [Buttons](#buttons)
- [Custom Macros](#custom-macros)
- [Custom Components](#custom-components)
- [Generating URLs](#generating-urls)

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

[](#installation)

To install through composer, run the following command from terminal:

```
composer require "laravie/html"

```

Next, add your new provider to the `providers` array of `config/app.php`:

```
'providers' => [

    // ...

    Collective\Html\HtmlServiceProvider::class,

],
```

Finally, add two class aliases to the `aliases` array of `config/app.php`:

```
'aliases' => [

    // ...

    'Form' => Collective\Html\FormFacade::class,
    'Html' => Collective\Html\HtmlFacade::class,

],
```

> Looking to install this package in [Lumen](http://lumen.laravel.com)? First of all, making this package compatible with Lumen will require some core changes to Lumen, which we believe would dampen the effectiveness of having Lumen in the first place. Secondly, it is our belief that if you need this package in your application, then you should be using Laravel anyway.

Opening A Form
--------------

[](#opening-a-form)

#### Opening A Form

[](#opening-a-form-1)

```
{!! Form::open(['url' => 'foo/bar']) !!}
    //
{!! Form::close() !!}
```

By default, a `POST` method will be assumed; however, you are free to specify another method:

```
echo Form::open(['url' => 'foo/bar', 'method' => 'put'])
```

> **Note:** Since HTML forms only support `POST` and `GET`, `PUT` and `DELETE` methods will be spoofed by automatically adding a `_method` hidden field to your form.

You may also open forms that point to named routes or controller actions:

```
echo Form::open(['route' => 'route.name'])

echo Form::open(['action' => 'Controller@method'])
```

You may pass in route parameters as well:

```
echo Form::open(['route' => ['route.name', $user->id]])

echo Form::open(['action' => ['Controller@method', $user->id]])
```

If your form is going to accept file uploads, add a `files` option to your array:

```
echo Form::open(['url' => 'foo/bar', 'files' => true])
```

CSRF Protection
---------------

[](#csrf-protection)

#### Adding The CSRF Token To A Form

[](#adding-the-csrf-token-to-a-form)

Laravel provides an easy method of protecting your application from cross-site request forgeries. First, a random token is placed in your user's session. If you use the `Form::open` method with `POST`, `PUT` or `DELETE` the CSRF token will be added to your forms as a hidden field automatically. Alternatively, if you wish to generate the HTML for the hidden CSRF field, you may use the `token` method:

```
echo Form::token();
```

#### Attaching The CSRF Filter To A Route

[](#attaching-the-csrf-filter-to-a-route)

```
Route::post('profile', ['before' => 'csrf', function() {
    //
}]);
```

Form Model Binding
------------------

[](#form-model-binding)

#### Opening A Model Form

[](#opening-a-model-form)

Often, you will want to populate a form based on the contents of a model. To do so, use the `Form::model` method:

```
echo Form::model($user, ['route' => ['user.update', $user->id]])
```

Now, when you generate a form element, like a text input, the model's value matching the field's name will automatically be set as the field value. So, for example, for a text input named `email`, the user model's `email` attribute would be set as the value. However, there's more! If there is an item in the Session flash data matching the input name, that will take precedence over the model's value. So, the priority looks like this:

1. Session Flash Data (Old Input)
2. Explicitly Passed Value
3. Model Attribute Data

This allows you to quickly build forms that not only bind to model values, but easily re-populate if there is a validation error on the server!

> **Note:** When using `Form::model`, be sure to close your form with `Form::close`!

#### Form Model Accessors

[](#form-model-accessors)

Laravel's [Eloquent Accessor](http://laravel.com/docs/5.2/eloquent-mutators#accessors-and-mutators) allow you to manipulate a model attribute before returning it. This can be extremely useful for defining global date formats, for example. However, the date format used for display might not match the date format used for form elements. You can solve this by creating two separate accessors: a standard accessor, *and/or* a form accessor.

To define a form accessor, create a `formFooAttribute` method on your model where `Foo` is the "camel" cased name of the column you wish to access. In this example, we'll define an accessor for the `date_of_birth` attribute. The accessor will automatically be called by the HTML Form Builder when attempting to pre-fill a form field when `Form::model()` is used.

Labels
------

[](#labels)

#### Generating A Label Element

[](#generating-a-label-element)

```
echo Form::label('email', 'E-Mail Address');
```

#### Specifying Extra HTML Attributes

[](#specifying-extra-html-attributes)

```
echo Form::label('email', 'E-Mail Address', ['class' => 'awesome']);
```

> **Note:** After creating a label, any form element you create with a name matching the label name will automatically receive an ID matching the label name as well.

Text, Text Area, Password &amp; Hidden Fields
---------------------------------------------

[](#text-text-area-password--hidden-fields)

#### Generating A Text Input

[](#generating-a-text-input)

```
echo Form::text('username');
```

#### Specifying A Default Value

[](#specifying-a-default-value)

```
echo Form::text('email', 'example@gmail.com');
```

> **Note:** The *hidden* and *textarea* methods have the same signature as the *text* method.

#### Generating A Password Input

[](#generating-a-password-input)

```
echo Form::password('password', ['class' => 'awesome']);
```

#### Generating Other Inputs

[](#generating-other-inputs)

```
echo Form::email($name, $value = null, $attributes = []);
echo Form::file($name, $attributes = []);
```

Checkboxes and Radio Buttons
----------------------------

[](#checkboxes-and-radio-buttons)

#### Generating A Checkbox Or Radio Input

[](#generating-a-checkbox-or-radio-input)

```
echo Form::checkbox('name', 'value');

echo Form::radio('name', 'value');
```

#### Generating A Checkbox Or Radio Input That Is Checked

[](#generating-a-checkbox-or-radio-input-that-is-checked)

```
echo Form::checkbox('name', 'value', true);

echo Form::radio('name', 'value', true);
```

Number
------

[](#number)

#### Generating A Number Input

[](#generating-a-number-input)

```
echo Form::number('name', 'value');
```

Date
----

[](#date)

#### Generating A Date Input

[](#generating-a-date-input)

```
echo Form::date('name', \Carbon\Carbon::now());
```

File Input
----------

[](#file-input)

#### Generating A File Input

[](#generating-a-file-input)

```
echo Form::file('image');
```

> **Note:** The form must have been opened with the `files` option set to `true`.

Drop-Down Lists
---------------

[](#drop-down-lists)

#### Generating A Drop-Down List

[](#generating-a-drop-down-list)

```
echo Form::select('size', ['L' => 'Large', 'S' => 'Small']);
```

#### Generating A Drop-Down List With Selected Default

[](#generating-a-drop-down-list-with-selected-default)

```
echo Form::select('size', ['L' => 'Large', 'S' => 'Small'], 'S');
```

#### Generating a Drop-Down List With an Empty Placeholder

[](#generating-a-drop-down-list-with-an-empty-placeholder)

This will create an `` element with no value as the very first option of your drop-down.

```
echo Form::select('size', ['L' => 'Large', 'S' => 'Small'], null, ['placeholder' => 'Pick a size...']);
```

#### Generating A Grouped List

[](#generating-a-grouped-list)

```
echo Form::select('animal', [
    'Cats' => ['leopard' => 'Leopard'],
    'Dogs' => ['spaniel' => 'Spaniel'],
]);
```

#### Generating A Drop-Down List With A Range

[](#generating-a-drop-down-list-with-a-range)

```
echo Form::selectRange('number', 10, 20);
```

#### Generating A List With Month Names

[](#generating-a-list-with-month-names)

```
echo Form::selectMonth('month');
```

Buttons
-------

[](#buttons)

#### Generating A Submit Button

[](#generating-a-submit-button)

```
echo Form::submit('Click Me!');
```

#### Generating A Button

[](#generating-a-button)

```
echo Form::button('Click Me!');
```

> **Note:** Default value for third parameter is true. As default, any value that you pass will be escaped.

```
echo Form::button(' null, 'attributes' => []]);
```

#### Calling A Custom Form Component

[](#calling-a-custom-form-component)

Using our example from above (specifically, the one with default values provided), you can call your Custom Component like so:

```
{{ Form::bsText('first_name') }}
```

This would result in something like the following HTML output:

```

    First Name

```

\##Generating URLs

#### link\_to

[](#link_to)

Generate a HTML link to the given URL.

```
echo link_to('foo/bar', $title = null, $attributes = [], $secure = null);
```

#### link\_to\_asset

[](#link_to_asset)

Generate a HTML link to the given asset.

```
echo link_to_asset('foo/bar.zip', $title = null, $attributes = [], $secure = null);
```

#### link\_to\_route

[](#link_to_route)

Generate a HTML link to the given named route.

```
echo link_to_route('route.name', $title = null, $parameters = [], $attributes = []);
```

#### link\_to\_action

[](#link_to_action)

Generate a HTML link to the given controller action.

```
echo link_to_action('HomeController@getIndex', $title = null, $parameters = [], $attributes = []);
```

###  Health Score

46

—

FairBetter than 93% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity43

Moderate usage in the ecosystem

Community29

Small or concentrated contributor base

Maturity81

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 55% 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 ~54 days

Recently: every ~181 days

Total

44

Last Release

1528d ago

Major Versions

v5.8.2 → v6.0.02019-08-29

5.8.x-dev → v6.0.12019-10-30

v6.0.1 → v7.0.02020-03-03

6.x-dev → v7.1.02020-09-07

PHP version history (7 changes)v5.1.0PHP &gt;=5.5.9

v5.3.0PHP &gt;=5.6.4

v5.5.0PHP &gt;=7.0

v5.6.0PHP &gt;=7.1

v5.6.3PHP &gt;=7.1.3

v6.0.0PHP &gt;=7.2

v7.3.0PHP ^7.2 || ^8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/172966?v=4)[Mior Muhammad Zaki](/maintainers/crynobone)[@crynobone](https://github.com/crynobone)

---

Top Contributors

[![crynobone](https://avatars.githubusercontent.com/u/172966?v=4)](https://github.com/crynobone "crynobone (409 commits)")[![taylorotwell](https://avatars.githubusercontent.com/u/463230?v=4)](https://github.com/taylorotwell "taylorotwell (92 commits)")[![mlantz](https://avatars.githubusercontent.com/u/1065551?v=4)](https://github.com/mlantz "mlantz (82 commits)")[![adamgoose](https://avatars.githubusercontent.com/u/611068?v=4)](https://github.com/adamgoose "adamgoose (38 commits)")[![tshafer](https://avatars.githubusercontent.com/u/299464?v=4)](https://github.com/tshafer "tshafer (35 commits)")[![GrahamCampbell](https://avatars.githubusercontent.com/u/2829600?v=4)](https://github.com/GrahamCampbell "GrahamCampbell (8 commits)")[![RobinMalfait](https://avatars.githubusercontent.com/u/1834413?v=4)](https://github.com/RobinMalfait "RobinMalfait (6 commits)")[![adambant](https://avatars.githubusercontent.com/u/700931?v=4)](https://github.com/adambant "adambant (5 commits)")[![alexandre-butynski](https://avatars.githubusercontent.com/u/671662?v=4)](https://github.com/alexandre-butynski "alexandre-butynski (5 commits)")[![ranabd36](https://avatars.githubusercontent.com/u/8455801?v=4)](https://github.com/ranabd36 "ranabd36 (5 commits)")[![tortuetorche](https://avatars.githubusercontent.com/u/5038872?v=4)](https://github.com/tortuetorche "tortuetorche (5 commits)")[![DarthRevan13](https://avatars.githubusercontent.com/u/109189018?v=4)](https://github.com/DarthRevan13 "DarthRevan13 (4 commits)")[![lucasmichot](https://avatars.githubusercontent.com/u/513603?v=4)](https://github.com/lucasmichot "lucasmichot (4 commits)")[![devinfd](https://avatars.githubusercontent.com/u/468399?v=4)](https://github.com/devinfd "devinfd (3 commits)")[![jackmcdade](https://avatars.githubusercontent.com/u/44739?v=4)](https://github.com/jackmcdade "jackmcdade (3 commits)")[![barryvdh](https://avatars.githubusercontent.com/u/973269?v=4)](https://github.com/barryvdh "barryvdh (3 commits)")[![AndersonFriaca](https://avatars.githubusercontent.com/u/14348255?v=4)](https://github.com/AndersonFriaca "AndersonFriaca (3 commits)")[![thujohn](https://avatars.githubusercontent.com/u/580699?v=4)](https://github.com/thujohn "thujohn (3 commits)")[![Anahkiasen](https://avatars.githubusercontent.com/u/1321596?v=4)](https://github.com/Anahkiasen "Anahkiasen (3 commits)")[![Vendin](https://avatars.githubusercontent.com/u/9011975?v=4)](https://github.com/Vendin "Vendin (3 commits)")

---

Tags

form-builderhtml-builderlaravelphplaravelhtmlform

### Embed Badge

![Health badge](/badges/laravie-html/health.svg)

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

###  Alternatives

[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9682.1M97](/packages/roots-acorn)[proengsoft/laravel-jsvalidation

Validate forms transparently with Javascript reusing your Laravel Validation Rules, Messages, and FormRequest

1.1k2.3M49](/packages/proengsoft-laravel-jsvalidation)[laravellux/html

HTML and Form Builders for the Laravel Framework

35239.2k3](/packages/laravellux-html)[konekt/html

HTML and Form Builders for the Laravel Framework

24403.2k5](/packages/konekt-html)[tomjamon/laravel-custom-html

Custom HTML generator for Laravel (Based on LaravelCollective HTML)

1018.6k](/packages/tomjamon-laravel-custom-html)[dragon-code/pretty-routes

Pretty Routes for Laravel

10058.7k4](/packages/dragon-code-pretty-routes)

PHPackages © 2026

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