Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP Laravel 4 Basics Blade & Forms Form Builder

Jarrod Tanton
Jarrod Tanton
Courses Plus Student 10,802 Points

Help for Others - Using Blade Syntax with a Framework (like bootstrap)

For those of you who watching this, that might want to have the ability to use the blade syntax for the form builder in combination with a framework like Bootstrap. Here are the steps.

  1. Create a new provider (you can use php artisan for this) In my case, I created one title BootstrapFormServiceProvider.

  2. In the boot method of the provider specify the new type of element you want to create and what it expects. (i.e. I wanted to use Bootstrap so I created a newStatic method for bsText using the syntax below.

Form::component('bsText', 'components.form.text', ['name', 'value' => null, 'attributes' => []]);

  1. Register the service provider by editing the app.php file in the confit folder. This is done by adding something like the below to the bottom of 'providers':


  1. run composer update

  2. Create the file that specifies how the bsText method you created in step 2 will work. In my case, the file will be stored at 'components.form.text' (what we specified in step 2) and will contain the following.

<fieldset class="form-group"> {{ Form::label($name, null, ['class' => 'control-label']) }} {{ Form::text($name, $value, array_merge(['class' => 'form-control'], $attributes)) }} </fieldset>

  1. Use the method in your view. In my case, I added this inside of my form:

{{ Form::bsText('title') }}

  1. Enjoy the benefits! Now just from typing that one line of code you will get the bootsrtap html needed for an input. Here's the html that will be generated!

<fieldset class="form-group"> <label for="title" class="control-label">Title</label> <input class="form-control" name="title" type="text" id="title"> </fieldset>

Hope this helps!

You can find more information on the laravel collective site: