PHPackages                             genealabs/laravel-casts - 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. genealabs/laravel-casts

Abandoned → [livewire/flux](/?search=livewire%2Fflux)ArchivedLibrary[Templating &amp; Views](/categories/templating)

genealabs/laravel-casts
=======================

Useful form macros for Laravel's Blade template engine.

0.13.3(5y ago)109261.2k↓22.9%11[11 issues](https://github.com/mikebronner/laravel-casts/issues)[4 PRs](https://github.com/mikebronner/laravel-casts/pulls)MITPHP

Since Mar 22Pushed 1y ago6 watchersCompare

[ Source](https://github.com/mikebronner/laravel-casts)[ Packagist](https://packagist.org/packages/genealabs/laravel-casts)[ GitHub Sponsors](https://github.com/mikebronner)[ RSS](/packages/genealabs-laravel-casts/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (13)Versions (148)Used By (0)

⚠️ This package has been archived in favor of FluxUI: . Feel free to continue to use this package until you can transition, but it will no longer receive updates.
======================================================================================================================================================================================

[](#️-this-package-has-been-archived-in-favor-of-fluxui-httpsfluxuidev-feel-free-to-continue-to-use-this-package-until-you-can-transition-but-it-will-no-longer-receive-updates)

Casts for Laravel
=================

[](#casts-for-laravel)

[![Casts for Laravel masthead image.](https://repository-images.githubusercontent.com/54227416/9eab2600-f1b2-11e9-9aa3-2da687ef463c)](https://repository-images.githubusercontent.com/54227416/9eab2600-f1b2-11e9-9aa3-2da687ef463c)

Requirements
------------

[](#requirements)

- PHP &gt;= 7.1.3
- Laravel &gt;= 5.5
- `jQuery` needs to be already loaded in your project
- `Bootstrap JS` (3 or 4) needs to be already loaded, if being used

Rationale
---------

[](#rationale)

This package is an effort to streamline and make form development more efficient in Laravel Blade views.

### Features

[](#features)

- Support for common CSS frameworks. (At this time only Bootstrap 3 and Bootstrap 4.beta, more coming soon.)
- Blade directives for elegant Blade view integration, providing concise syntax, reducing form boilerplate 10-fold.
- DateTime Picker for Bootstrap 3.

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

[](#installation)

1. Install the package:

```
composer require genealabs/laravel-casts
```

3. Publish the required assets:

```
php artisan casts:publish --assets
```

Usage
-----

[](#usage)

The following shows all elements using Bootstrap 3:

[![screen shot 2017-03-03 at 7 53 47 am](https://cloud.githubusercontent.com/assets/1791050/23557961/c0860684-ffe6-11e6-8218-c54377b42804.png)](https://cloud.githubusercontent.com/assets/1791050/23557961/c0860684-ffe6-11e6-8218-c54377b42804.png)

### Blade Directives

[](#blade-directives)

The following Blade directives developing forms a snap:

```
@form(['url' => ''])
    @errors("intro text", ["html" => "attributes"])
    @text('text', '', ['placeholder' => 'Placeholder Text', 'label' => 'Text Input'])
    @number('number', '', ['placeholder' => 'Placeholder Text', 'label' => 'Number Input'])
    @password('password', ['placeholder' => 'Placeholder Text', 'label' => 'Password Input'])
    @date('date', '', ['placeholder' => 'Placeholder Text', 'label' => 'Date'])
    @datetime('datetime', '', ['placeholder' => 'Placeholder Text', 'label' => 'DateTime'])
    @email('email', '', ['placeholder' => 'Placeholder Text', 'label' => 'Email Input'])
    @url('url', '', ['placeholder' => 'Placeholder Text', 'label' => 'Url Input'])
    @search ('search', 'search term', ['placeholder' => 'Placeholder Text', 'label' => 'Search Input'])
    @color ('color', '#ff0000', ['placeholder' => 'Placeholder Text', 'label' => 'Color Input'])
    @range ('range', 5, ['placeholder' => 'Placeholder Text', 'label' => 'Range Input'])
    @tel ('tel', '1234567890', ['placeholder' => 'Placeholder Text', 'label' => 'Tel Input'])
    @week ('week', 3, ['placeholder' => 'Placeholder Text', 'label' => 'Week Input'])
    @month ('month', 'January', ['placeholder' => 'Placeholder Text', 'label' => 'Month Input'])
    @file('file', ['placeholder' => 'Placeholder Text', 'label' => 'File Input'])
    @textarea('textarea', '', ['placeholder' => 'Placeholder Text', 'label' => 'Textarea', 'rows' => 7])
    @checkbox('checkbox', 'test', true, ['placeholder' => 'Placeholder Text', 'label' => 'Checkbox'])
    @radio('radio', 'test', true, ['placeholder' => 'Placeholder Text', 'label' => 'Radio'])
    @switch('fieldname', 'true value', $isChecked, ['label' => 'Switch', 'label' => 'Switch', 'onText' => 'Available', 'onColor' => 'success', 'offText' => 'Unavailable', 'offColor' => 'danger'])
    @select('select', [1, 2, 3, 4], null, ['placeholder' => 'Placeholder Text', 'label' => 'Select'])
    @selectMonths('select_months', null, ['placeholder' => 'Placeholder Text', 'label' => 'Select'])
    @selectWeekdays('select_weekdays', null, ['placeholder' => 'Placeholder Text', 'label' => 'Select Weekdays']) @selectRange('selectRange', 1, 21, null, ['class' => 'form-control', 'placeholder' => 'Placeholder Text', 'label' => 'Select Range'])
    @selectRangeWithInterval('selectRangeWithInterval', 1, 21, 3, null, ['class' => 'form-control', 'placeholder' => 'Placeholder Text', 'label' => 'Select Range With Interval'])
    @combobox('combobox', [1, 2, 3, 4], null, ['class' => 'form-control', 'placeholder' => 'Placeholder Text', 'label' => 'Combobox'])
    @submit('submit', ['class' => 'btn btn-success', 'label' => 'Submit Button'])
@endform
```

#### `@form` / `{!! Form::open() !!}`

[](#form---formopen-)

```
@form ($model, ['class' => '', 'labelWidth' => '', 'fieldWidth' => '', 'framework' => ''])
```

- `$model`: (optional) used to pre-populate a model-based form.
- `class`: (optional)
- `offset`: (optional, default: 3)
- `labelWidth`: (optional, default: 3)
- `fieldWidth`: (optional, default: 9)
- `framework`: (optional)

#### `@errors` / `{!! Form::errors() !!}`

[](#errors---formerrors-)

```
@errors (string $intro = "", array $options = [])
```

- `$intro`: an optional brief pre-text to the errors list.
- `$options`: (default: \[\]) will be rendered as html tag attributes.

#### `@label` / `{!! Form::label() !!}`

[](#label---formlabel-)

```
@label ($name, $label = null, array $options = [], $escapeHtml = true)
```

- `$name`: used for the `for=` attribute on the label.
- `$label`: (default: null) the label text.
- `$options`: (default: \[\]) array of options, including `class`.
- `$escapeHtml`: (default: true) set this to false if your label should render HTML.

**Note:** labels are rendered automatically when using frameworks.

#### Input controls

[](#input-controls)

The following controls use the same syntax:

- `@text` / `{!! Form::text() !!}`
- `@date` / `{!! Form::date() !!}`
- `@datetime` / `{!! Form::datetime() !!}`
- `@email` / `{!! Form::email() !!}`
- `@url` / `{!! Form::url() !!}`
- `@textarea` / `{!! Form::textarea() !!}`

```
@text ($name, $value = null, $options = [])
```

- `$name`: name of the control, used to submit form values.
- `$value`: (default: null) value of the control, if you need to prepopulate it. It will automatically populate old form values if validation fails.
- `$options`: (default: \[\]) array of options, including `class`.

#### `@switch` / `{!! Form::switch() !!}`

[](#switch---formswitch-)

```
@switch ('fieldname', 'active value', $isActivated, [label' => 'Switch', 'onText' => 'Available', 'offText' => 'Unavailable', 'onColor' => 'success', 'offColor' => 'danger'])
```

#### `@select` / `{!! Form::select() !!}`

[](#select---formselect-)

```
@select ($name, $list = [], $selected = null, $options = [])
```

- `$name`: name of the control, used to submit form values.
- `$list`: (default: \[\]) array of key-value pairs used to create the select list options.
- `$selected`: (default: null) the value of the selected options.
- `$options`: (default: \[\]) array of options, including `class`.

#### `@selectMonths` / `{!! Form::selectMonths() !!}`

[](#selectmonths---formselectmonths-)

```
@selectMonths ($name, $selected = null, $options = [])
```

- `$name`: name of the control, used to submit form values.
- `$selected`: (default: null) the value of the selected options.
- `$options`: (default: \[\]) array of options, including `class`.

#### `@selectWeekdays` / `{!! Form::selectWeekdays() !!}`

[](#selectweekdays---formselectweekdays-)

```
@selectWeekdays ($name, $selected = null, $options = [])
```

- `$name`: name of the control, used to submit form values.
- `$selected`: (default: null) the value of the selected options.
- `$options`: (default: \[\]) array of options, including `class`.

#### `@selectRangeWithInterval` / `{!! Form::selectRangeWithInterval() !!}`

[](#selectrangewithinterval---formselectrangewithinterval-)

```
@selectRangeWithInterval(string $name, int $start, int $end, int $interval, int $value = null, array $options = [])
```

- `$name`: name of the control, used to submit form values.
- `$start`: starting value of the list.
- `$end`: ending value of the list.
- `$interval`: interval value.
- `$value`: selected value.
- `$options`: (default: \[\]) array of options, including `class`.

### CSS Framework Support

[](#css-framework-support)

Taking advantage of framework support will handle all error validation presentation, as well as generation of labels and all the necessary form control boilerplate.

Additional framework support is planned, possibly including:

- Foundation
- Skeleton
- Semantic UI

If there's a framework you would like included, feel free to reach out by opening an issue with the pertinent details.

#### Bootstrap 3

[](#bootstrap-3)

To have a form render for Bootstrap 3, specify the framework and form orientation in the `@form` directive:

```
@form(['url' => '', 'class' => 'form-horizontal', 'framework' => 'bootstrap3'])
```

Additionally, to enable the date/time picker, add the following to your JavaScript file for the page rendering the date fields:

```
if (window.$) {
    $(function () {
        if ( $.isFunction($.fn.datetimepicker) ) {
            $('input[type=date]').datetimepicker({
                format: 'LL'
            });

            $('input[type=datetime]').datetimepicker({
                format: 'LLL',
                sideBySide: true
            });
        }
    });
}
```

You can include the library using Gulp and NPM (preferred), or use a CDN.

##### Gulp / NPM

[](#gulp--npm)

1. `npm install save-dev bootstrap-datetimepicker-npm`
2. Then require the library in your `/resources/assets/js/app.js` file (after jQuery and Bootstrap have been required):

```
require('bootstrap-datetimepicker-npm');

```

3. Don't forget to include the CSS as well in `/resources/assets/sass/app.sass`:

```
// DateTimePicker
@import "./node_modules/bootstrap-datetimepicker-npm/src/sass/bootstrap-datetimepicker-build";

```

4. Finally, edit your `/gulpfile.js` as needed, and run `gulp`.

##### CDNs

[](#cdns)

Add the following references to the page(s) or your main layout file. You will need to have jQuery and Bootstrap libraries included as well.

```

```

#### Bootstrap 4 (alpha 3)

[](#bootstrap-4-alpha-3)

Nearly the same as above:

```
@form(['url' => '', 'class' => 'form-horizontal', 'framework' => 'bootstrap4'])
```

Testing
-------

[](#testing)

- Add the following entry to your `phpunit.xml` config file: ```
    ```

```
      ./vendor/genealabs/laravel-casts/tests

```

```

- Run `vendor/bin/phpunit` from the base directory of your project.

```

###  Health Score

45

—

FairBetter than 93% of packages

Maintenance27

Infrequent updates — may be unmaintained

Popularity50

Moderate usage in the ecosystem

Community16

Small or concentrated contributor base

Maturity71

Established project with proven stability

 Bus Factor1

Top contributor holds 99.6% 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 ~12 days

Recently: every ~4 days

Total

139

Last Release

2071d ago

PHP version history (5 changes)0.1.0PHP &gt;=5.5.9

0.3.0PHP &gt;=7.0.0

0.7.12PHP &gt;=7.1.3

0.10.2PHP ^7.2

0.11.0PHP ^7.2.5

### Community

Maintainers

![](https://www.gravatar.com/avatar/4374bfc5d8583aa8c25c5080f1fcfaf09027822f47724ba6b64abc564945c80a?d=identicon)[mikebronner](/maintainers/mikebronner)

---

Top Contributors

[![mikebronner](https://avatars.githubusercontent.com/u/1791050?v=4)](https://github.com/mikebronner "mikebronner (528 commits)")[![felipepodesta](https://avatars.githubusercontent.com/u/102604?v=4)](https://github.com/felipepodesta "felipepodesta (1 commits)")[![gitter-badger](https://avatars.githubusercontent.com/u/8518239?v=4)](https://github.com/gitter-badger "gitter-badger (1 commits)")

---

Tags

blade-directivesformslaraveltailwindcss

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/genealabs-laravel-casts/health.svg)

```
[![Health](https://phpackages.com/badges/genealabs-laravel-casts/health.svg)](https://phpackages.com/packages/genealabs-laravel-casts)
```

###  Alternatives

[laravel/pulse

Laravel Pulse is a real-time application performance monitoring tool and dashboard for your Laravel application.

1.7k12.1M99](/packages/laravel-pulse)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9682.1M97](/packages/roots-acorn)[tallstackui/tallstackui

TallStackUI is a powerful suite of Blade components that elevate your workflow of Livewire applications.

703141.0k7](/packages/tallstackui-tallstackui)[pressbooks/pressbooks

Pressbooks is an open source book publishing tool built on a WordPress multisite platform. Pressbooks outputs books in multiple formats, including PDF, EPUB, web, and a variety of XML flavours, using a theming/templating system, driven by CSS.

44643.1k1](/packages/pressbooks-pressbooks)[mati365/ckeditor5-livewire

CKEditor 5 integration for Laravel Livewire

413.9k](/packages/mati365-ckeditor5-livewire)[evanschleret/lara-mjml

Just a service provider for Spatie's MJML wrapper

1722.0k](/packages/evanschleret-lara-mjml)

PHPackages © 2026

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