PHPackages                             sahibalejandro/laravel-form-helpers - 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. [Database &amp; ORM](/categories/database)
4. /
5. sahibalejandro/laravel-form-helpers

ActiveLibrary[Database &amp; ORM](/categories/database)

sahibalejandro/laravel-form-helpers
===================================

Handle form model binding, old input binding and validation error messages in a clean and easy way.

1.3.2(4y ago)82.4k3MITPHPPHP &gt;=5.5.9

Since Jul 29Pushed 4y ago2 watchersCompare

[ Source](https://github.com/sahibalejandro/laravel-form-helpers)[ Packagist](https://packagist.org/packages/sahibalejandro/laravel-form-helpers)[ RSS](/packages/sahibalejandro-laravel-form-helpers/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (2)Versions (14)Used By (0)

Laravel Form Helpers
====================

[](#laravel-form-helpers)

[![Build Status](https://camo.githubusercontent.com/c8d16a6576a29dadd587af8434b6a69751189698e66c3f447ffab73668878c6a/68747470733a2f2f7472617669732d63692e6f72672f7361686962616c656a616e64726f2f6c61726176656c2d666f726d2d68656c706572732e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/sahibalejandro/laravel-form-helpers)[![Latest Stable Version](https://camo.githubusercontent.com/0b90d9175a8ba0f52ecf6c6b48b108ca330f14d4df900796b2f487e3604c09ad/68747470733a2f2f706f7365722e707567782e6f72672f7361686962616c656a616e64726f2f6c61726176656c2d666f726d2d68656c706572732f762f737461626c65)](https://packagist.org/packages/sahibalejandro/laravel-form-helpers)[![Total Downloads](https://camo.githubusercontent.com/c2590cf26470c6509232f3ae6065f446b7b95c5f28b5e2971be465080864158b/68747470733a2f2f706f7365722e707567782e6f72672f7361686962616c656a616e64726f2f6c61726176656c2d666f726d2d68656c706572732f646f776e6c6f616473)](https://packagist.org/packages/sahibalejandro/laravel-form-helpers)[![License](https://camo.githubusercontent.com/8a738228645a461a57b33ae53995910820be3ca28c2960cb9aa00c56ae21fdde/68747470733a2f2f706f7365722e707567782e6f72672f7361686962616c656a616e64726f2f6c61726176656c2d666f726d2d68656c706572732f6c6963656e7365)](https://packagist.org/packages/sahibalejandro/laravel-form-helpers)

A set of blade directives that automatically fill forms using the [old input](https://laravel.com/docs/5.2/requests#old-input)or an [Eloquent](https://laravel.com/docs/5.2/eloquent)model, it also helps you to display [validation error messages](https://laravel.com/docs/5.2/validation#working-with-error-messages)in a clean and easy way.

Example
-------

[](#example)

See how easy is to do cool stuff with these directives, for example if you are using [Bootstrap](https://getbootstrap.com) for your markup, you can do something like this:

```

    @form($model)

        @error('name')

```

And in the case of the user is redirected back with errors, the result will be:

```

        Error message

```

¡It's *awesame*!

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

[](#installation)

Install with composer, just run the command:

```
composer require sahibalejandro/laravel-form-helpers
```

Then add the service provider to your `config/app.php` file:

```
'providers' => [
    Sahib\Form\FormServiceProvider::class,
];
```

That's all.

Configuration
-------------

[](#configuration)

Optionally you can publish the configuration file with this command:

```
php artisan vendor:publish --provider=Sahib\Form\FormServiceProvider
```

After that you can edit the `config/form-helpers.php` file.

Usage
-----

[](#usage)

### @form

[](#form)

`@form([ Model $model = null ])`

Use the optional `@form` directive to bind a model to your form.
Ignore this directive if you just want the [old input](https://laravel.com/docs/5.2/requests#old-input) binding and no the model binding.

```

    @form($user)

```

### @input

[](#input)

`@input(string $attribute [, string $default = null ])`

Use the `@input` directive to assign the value to an input field:

```

```

This will result in the following markup:

```

```

### @text

[](#text)

`@text(string $attribute [, string $default = null ])`

Use the `@text` directive to assign the value to a textarea field:

```
@text('description')
@text('bio', 'Default')
```

This will result in the following markup:

```

Default
```

### @checkbox

[](#checkbox)

`@checkbox(string $attribute [, mixed $value = 1 [, boolean $checked = false ]])`

Use the `@checkbox` to set the value and the state of a checkbox:

```

```

This will result in the following markup:

```

```

### @radio

[](#radio)

`@radio(string $attribute [, mixed $value = 1 [, boolean $checked = false ]])`

The `@radio` directive is used in the same way as `@checkbox` directive, in fact is just an alias:

```

```

This will result in the following markup:

```

```

### @options

[](#options)

`@options(array $options, string $attribute [, mixed $default = null [, string $placeholder = null ]])`

Use the `@options` directive to display a list of options for a select field.

*Note: It also works with **select multiple** fields when the model's attribute, old input or `$default` value is an array.*

Let's say we pass an array named `$cardTypes` to the view and use it with the `@options`directive:

```
$cardTypes = [
    'VISA' => 'Visa',
    'MC'   => 'Master Card',
    'AME'  => 'American Express',
];
```

```

    @options($cardTypes, 'card_type')

```

This will result in the following markup:

```

    Visa
    Master Card
    American Express

```

Of course you can set a default selected option:

```

    @options($cardTypes, 'card_type', 'MC')

```

And the result will be:

```

    Visa
    Master Card
    American Express

```

Also you can define a *placeholder* option:

```

    @options($cardTypes, 'card_type', null, 'Select a card type')

```

The result will be:

```

    Select a card type
    Visa
    Master Card
    American Express

```

### @error

[](#error)

`@error(string $attribute [, string $template = null ])`

Use the `@error` directive to display a validation error message, this directive will check for you if the error exists or not.

```

@error('name')
```

Then when the user is redirected back with errors, the result will be:

```

The name field fails validation.
```

Note that the `@error` directive is [Bootstrap](https://getbootstrap.com) friendly by default, but you can define a custom template inline or in the config file:

```
@error('name', ':message')
```

And the result will be:

```
Error message
```

See how easy is to do cool stuff with `@error` directive, for example if you are using [Bootstrap](https://getbootstrap.com) for your markup, you can do something like this:

```

    @error('name')

```

And in the case the user is redirected back with errors, the result will be:

```

    Error message

```

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity27

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity65

Established project with proven stability

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

Recently: every ~505 days

Total

13

Last Release

1551d ago

### Community

Maintainers

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

---

Top Contributors

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

---

Tags

laravelvalidationhelpershtmleloquentsessionforminput

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/sahibalejandro-laravel-form-helpers/health.svg)

```
[![Health](https://phpackages.com/badges/sahibalejandro-laravel-form-helpers/health.svg)](https://phpackages.com/packages/sahibalejandro-laravel-form-helpers)
```

###  Alternatives

[watson/validating

Eloquent model validating trait.

9723.3M47](/packages/watson-validating)[relaticle/custom-fields

User Defined Custom Fields for Laravel Filament

15828.6k](/packages/relaticle-custom-fields)[mvanduijker/laravel-model-exists-rule

Validation rule to check if a model exists

22194.5k1](/packages/mvanduijker-laravel-model-exists-rule)[mnabialek/laravel-eloquent-filter

Allows filtering Eloquent queries by input filters

2614.5k](/packages/mnabialek-laravel-eloquent-filter)

PHPackages © 2026

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