LaravelPackages.net
Acme Inc.
Toggle sidebar
mwi/laravel-forms

MWI Starter Forms extends Laravel Collective HTML

12.606
0
v2.0.0
About mwi/laravel-forms

mwi/laravel-forms is a Laravel package for mwi starter forms extends laravel collective html. It currently has 0 GitHub stars and 12.606 downloads on Packagist (latest version v2.0.0). Install it with composer require mwi/laravel-forms. Discover more Laravel packages by mwi or browse all Laravel packages to compare alternatives.

Last updated

MWI Laravel Forms

MWI Laravel froms is an extension of Laravel Collective Forms & HTML. It utilized components to build out bootsrap ready form inputs with parsley client side validation and select2 funcionality.

Installation

$ composer require mwi/laravel-forms

Service Provider

If you're on laravel 5.5 or later the service provider will be automatially loaded, if not, add to your config/app.php providers

'providers' => [
    // ...
    MWI\LaravelForms\ServiceProvider::class,
    // ...
],

HTML Service Provider

You will also need to add the Laravel Collection provider if you haven't already

'providers' => [
    // ...
    Collective\Html\HtmlServiceProvider::class,
    // ...
],

HTML Aliases

If you have't already you can add Laravel Collective HTML aliases

'aliases' => [
    // ...
    'Form' => Collective\Html\FormFacade::class,
    'Html' => Collective\Html\HtmlFacade::class,
    // ...
],

Publish

Last but not least be sure to publish

php artisan vendor:publish --provider="MWI\LaravelForms\ServiceProvider"

Usage

Here are the current tags available and how to best utilize them.

Text Field

Only the first parameter is required.

Variations available are mwitext, mwitextarea, mwidate, mwidaterange, mwiemail, mwipass and mwinumber.

Form::mwitext('field_name')
Form::mwitext('field_name_two', $default_value, ['class' => 'class-name'], 'Custom Label')

// No default value with attributes
Form::mwitext('name', null, ['class' => 'class-name'])

Radio Options

Form::mwiradio('Set Label', 'field_name', ['option_one', 'option_two'], 'option_one', ['class' => 'class-name'])

Select Field

Variations available are mwiselect and mwifilter.

Form::mwiselect('field_name', $options)
Form::mwiselect('field_name_two', ['this' => 'that', 'them' => 'they'], $default_value, ['class' => 'class-name'])

// No default value with attributes
Form::mwiselect('state', $options, null, ['class' => 'class-name'])

Structure

All tags are wrapped in a div.form-group and contain a label, input and error message container. It's recommended to additionally wrap elements in rows/grids as follows.

<div class="row">
    <div class="col-md-6">
        {{ Form::mwitext('field_name', $field_value, $attributes) }}
    </div>
    <div class="col-md-6">
        {{ Form::mwitext('field2_name', $field2_value, ['required', 'class' => 'text-red']) }}
    </div>
</div>

Additionaly the password field already contains col-6 grids, so...

<div class="row">
    {{ Form::mwipass('password', ['required']) }}
</div>

Would produce...

<div class="row">
    <div class="col-md-6">
        <div class="form-group">
            {{ Form::label('password', null, ['class' => 'control-label']) }}
            {{ Form::password('password', ['class' => 'form-control', 'id' => 'password', 'required']) }}
            <small class="help-block">{{ $errors->first('password') }}</small>
        </div>
    </div>
    <div class="col-md-6">
        <div class="form-group">
            {{ Form::label('password_confirmation', null, ['class' => 'control-label']) }}
            {{ Form::password('password_confirmation' . '_confirmation', ['class' => 'form-control']) }}
            <small class="help-block">{{ $errors->first('password_confirmation') }}</small>
        </div>
    </div>
</div>
Comments