Phill Sparks

Fork me on GitHub

Bootsparks Bundle

Twitter’s Bootstrap Forms support in Laravel. More to come in the future!


Install via the Artisan CLI:

php artisan bundle:install bootsparks

Bundle Registration

Add the following to your application/bundles.php file:

'bootsparks' => array(
    'autoloads' => array(
        'map' => array(
            'Bootsparks\\Form' => '(:bundle)/form.php',

Class Alias

Bootsparks\Form extends Laravel\Form so you can use it to replace your existing form code. To do this you’ll need to edit application/config/application.php and update the alias for Form.


Here’s an example of a Login form using Bootsparks:

	<h1>Log in</h1>

	<?php echo Form::open(URL::to('login'), 'POST', array('class' => Form::TYPE_HORIZONTAL)); ?>
	<?php echo Form::token(); ?>
	<?php echo Form::hidden('from', Input::get('from', Request::uri() === 'login' ? '' : Request::uri())); ?>

	<?php if ($errors->has('login')): ?>
		<?php echo $errors->first('login', '<div class="alert-message error">:message</div>'); ?>
	<?php endif; ?>

	<?php echo Form::field('email', 'email', 'E-mail Address', array(Input::get('email')), array('error' => $errors->has('email'))); ?>
	<?php echo Form::field('password', 'password', 'Password', array(), array('error' => $errors->has('password'))); ?>
	<?php echo Form::field('labelled_checkbox', 'remember', '', array('Use a '.HTML::link('cookies', 'cookie', array('title' => 'Find out more about the cookies we use and how to delete them', 'rel' => 'twipsy', 'target' => '_blank')).' to remember my details', 'yes')); ?>

	<?php echo Form::actions(Form::submit("Log in", array('class' => 'primary'))); ?>

	<?php echo Form::close(); ?>

The Form::field method allows you to generate a field for any Form:: field. The parameters are: