Documentation
Form
The form helper contains methods that assist in working with forms.
open([mixed $action = null, [array $attributes = null]])
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'));
macro(string $name, Closure $macro)
Registers a custom macro.
// Registering a Form macro Form::macro('my_field', function() { return '<input type="text" name="my_field">'; }); // Calling a custom Form macro echo Form::my_field(); // Registering a Form macro with parameters Form::macro('my_field', function($value = '') { return '<input type="text" name="my_field" value="'.$value.'">'; }); // Calling a custom Form macro with parameters echo Form::my_field('Monstra');
input(string $name, [string $value = null, [array $attributes = null]])
Create a form input. Text is default input type.
echo Form::input('username', $username);
hidden(string $name, [string $value = null, [array $attributes = null]])
Create a hidden form input.
echo Form::hidden('user_id', $user_id);
password(string $name, [string $value = null, [array $attributes = null]])
Create a password form input.
echo Form::password('password');
file(string $name, [array $attributes = null])
Creates a file upload form input.
echo Form::file('image');
checkbox(string $name, [string $value = null, [boolean $checked = false, [array $attributes = null]]])
Creates a checkbox form input.
echo Form::checkbox('i_am_not_a_robot');
radio(string $name, [string $value, [boolean $checked = false, [array $attributes = null]]])
Creates a radio form input.
echo Form::radio('i_am_not_a_robot');
textarea(string $name, [string $body = '', [array $attributes = null]])
Creates a textarea form input.
echo Form::textarea('text', $text);
select(string $name, [array $options = null, [string $selected = null, [array $attributes = null]]])
Creates a select form input.
echo Form::select('themes', array('default', 'classic', 'modern'));
submit(string $name, string $value, [array $attributes = null]]])
Creates a submit form input.
echo Form::submit('save', 'Save');
button(string $name, string $body, [array $attributes = null]]])
Creates a button form input.
echo Form::button('save', 'Save Profile', array('type' => 'submit'));
label(string $name, string $text, [array $attributes = null]]])
Creates a form label.
echo Form::label('save', 'Save Profile', array('type' => 'submit'));
close()
Create closing form tag.
echo Form::close();