socieboy/forms

Bootstrap form builder for Laravel

Installs: 23

Dependents: 0

Suggesters: 0

Security: 0

Stars: 4

Watchers: 2

Forks: 2

Open Issues: 0

Type:package

dev-master 2015-08-05 18:41 UTC

This package is auto-updated.

Last update: 2024-04-07 14:15:00 UTC


README

Installation

Add to your composer.json file the package.

"socieboy/forms" : "dev-master"

Update your dependencies

composer update

After install this package you have to set the service provider on your config/app.php file

Socieboy\Forms\FormsServiceProvider::class

Copy the config file to your config directory.

php artisan vendor:publish

Usage

{!! checkbox('checkbox') !!}

<div class="form-group">
	<div class="checkbox">
		<label>
			<input class="" name="checkbox" type="checkbox"> Checkbox
		</label>
	</div>
</div>

-----------------

{!! text('text', 'hello') !!}

<div class="form-group">
    <label for="Text">Text</label>
    <input class="form-control" name="text" type="text" value="hello">
</div>

-----------------

{!! radio('radio') !!}

<div class="form-group">
    <label for="Radio">Radio</label>
    <input checked="checked" name="radio" type="radio" value="radio">
</div>

-----------------

{!! select('select', [
    'USA' => 'United States of America',
    'MXN' => 'Mexico',
    'Other' => 'Other'], 'MXN')
!!}

<div class="form-group">
    <label for="Select">Select</label>
    <select class="form-control" name="select">
        <option value="">Select</option>
        <option value="USA">United States of America</option>
        <option value="MXN" selected="selected">Mexico</option>
        <option value="Other">Other</option>
    </select>
</div>

-----------------

{!! email('email', null, ['placeholder' => 'email@example.com']) !!}

<div class="form-group">
    <label for="Email">Email</label>
    <input placeholder="email@example.com" class="form-control" name="email" type="email">
</div>

-----------------

{!! email('email', null, ['placeholder' => 'email@example.com', 'icon' => 'glyphicon glyphicon-envelope']) !!}

<div class="input-group">
  	<span class="input-group-addon"><span class="glyphicon glyphicon-envelope"></span></span>
  	<input placeholder="email@example.com" class="form-control" name="email" type="email">
</div>


-----------------

{!! sfile('image') !!}

<div class="form-group ">
    <label for="imagen">Imagen</label>
    <input name="imagen" type="file">
</div>

If you want to edit some of the templates for each control, just publish the assets.

php artisan vendor:publish --tag=form-builder-views

On your views directory you will find this path.

views/vendor/socieboy/forms 

So for example, if you want to create a view for file control, just create another view with the name of the control.

file.blade.php

Then just set your css template, and you can use the variables

$control
$label
$icon
$error

By the way the package has support to display the erros if the field has validation.