Code Monkey home page Code Monkey logo

forms's Introduction

Laravel 5.1 Bootstrap Form Builder

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 protected]']) !!}

<div class="form-group">
    <label for="Email">Email</label>
    <input placeholder="[email protected]" class="form-control" name="email" type="email">
</div>

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

{!! email('email', null, ['placeholder' => '[email protected]', 'icon' => 'glyphicon glyphicon-envelope']) !!}

<div class="input-group">
  	<span class="input-group-addon"><span class="glyphicon glyphicon-envelope"></span></span>
  	<input placeholder="[email protected]" 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.

forms's People

Contributors

socieboy avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.