The form class contains methods that assist in working with forms.
Create an opening HTML form tag.
// Form will submit back to the current page using POST echo Form::open(); // Form will submit to 'search' using GET echo Form::open('search', array('method' => 'get')); // When "file" inputs are present, you must include the "enctype" echo Form::open(null, array('enctype' => 'multipart/form-data'));
Registers a custom macro.
// Registering a Form macro Form::macro('my_field', function() { return ''; }); // Calling a custom Form macro echo Form::my_field(); // Registering a Form macro with parameters Form::macro('my_field', function($value = '') { return ''; }); // Calling a custom Form macro with parameters echo Form::my_field('Monstra');
Create a form input. Text is default input type.
echo Form::input('username', $username);
Create a hidden form input.
echo Form::hidden('user_id', $user_id);
Create a password form input.
echo Form::password('password');
Creates a file upload form input.
echo Form::file('image');
Creates a checkbox form input.
echo Form::checkbox('i_am_not_a_robot');
Creates a radio form input.
echo Form::radio('i_am_not_a_robot');
Creates a textarea form input.
echo Form::textarea('text', $text);
Creates a select form input.
echo Form::select('themes', array('default', 'classic', 'modern'));
Creates a submit form input.
echo Form::submit('save', 'Save');
Creates a button form input.
echo Form::button('save', 'Save Profile', array('type' => 'submit'));
Creates a form label.
echo Form::label('save', 'Save Profile', array('type' => 'submit'));
Create closing form tag.
echo Form::close();