FormBuilder
class FormBuilder (View source)
Traits
MacroableTrait |
Properties
static protected array | $macros | The registered string macros. | from MacroableTrait |
protected HtmlBuilder | $html | The HTML builder instance. | |
protected UrlGenerator | $url | The URL generator instance. | |
protected string | $csrfToken | The CSRF token used by the form builder. | |
protected Store | $session | The session store implementation. | |
protected mixed | $model | The current model instance for the form. | |
protected array | $labels | An array of label names we've created. | |
protected array | $reserved | The reserved form open attributes. | |
protected array | $spoofedMethods | The form methods that should be spoofed, in uppercase. | |
protected array | $skipValueTypes | The types of inputs to not fill values on by default. |
Methods
static void | macro(string $name, callable $macro) Register a custom macro. | from MacroableTrait |
static boolean | hasMacro(string $name) Checks if macro is registered | from MacroableTrait |
static mixed | __callStatic(string $method, array $parameters) Dynamically handle calls to the class. | from MacroableTrait |
mixed | __call(string $method, array $parameters) Dynamically handle calls to the class. | from MacroableTrait |
void | __construct(HtmlBuilder $html, UrlGenerator $url, $csrfToken) Create a new form builder instance. | |
string | open(array $options = array()) Open up a new HTML form. | |
string | model(mixed $model, array $options = array()) Create a new model based form builder. | |
void | setModel(mixed $model) Set the model instance on the form builder. | |
string | close() Close the current form. | |
string | token() Generate a hidden field with the current CSRF token. | |
string | label(string $name, string $value = null, array $options = array()) Create a form label element. | |
string | formatLabel(string $name, string|null $value) Format the label value. | |
string | input(string $type, string $name, string $value = null, array $options = array()) Create a form input field. | |
string | text(string $name, string $value = null, array $options = array()) Create a text input field. | |
string | password(string $name, array $options = array()) Create a password input field. | |
string | hidden(string $name, string $value = null, array $options = array()) Create a hidden input field. | |
string | email(string $name, string $value = null, array $options = array()) Create an e-mail input field. | |
string | url(string $name, string $value = null, array $options = array()) Create a url input field. | |
string | file(string $name, array $options = array()) Create a file input field. | |
string | textarea(string $name, string $value = null, array $options = array()) Create a textarea input field. | |
array | setTextAreaSize(array $options) Set the text area size on the attributes. | |
array | setQuickTextAreaSize(array $options) Set the text area size using the quick "size" attribute. | |
string | number(string $name, string|null $value = null, array $options = array()) Create a number input field. | |
string | select(string $name, array $list = array(), string $selected = null, array $options = array()) Create a select box field. | |
string | selectRange(string $name, string $begin, string $end, string $selected = null, array $options = array()) Create a select range field. | |
string | selectYear() Create a select year field. | |
string | selectMonth(string $name, string $selected = null, array $options = array(), string $format = '%B') Create a select month field. | |
string | getSelectOption(string $display, string $value, string $selected) Get the select option for the given value. | |
string | optionGroup(array $list, string $label, string $selected) Create an option group form element. | |
string | option(string $display, string $value, string $selected) Create a select element option. | |
string | getSelectedValue(string $value, string $selected) Determine if the value is selected. | |
string | checkbox(string $name, mixed $value = 1, bool $checked = null, array $options = array()) Create a checkbox input field. | |
string | radio(string $name, mixed $value = null, bool $checked = null, array $options = array()) Create a radio button input field. | |
string | checkable(string $type, string $name, mixed $value, bool $checked, array $options) Create a checkable input field. | |
bool | getCheckedState(string $type, string $name, mixed $value, bool $checked) Get the check state for a checkable input. | |
bool | getCheckboxCheckedState(string $name, mixed $value, bool $checked) Get the check state for a checkbox input. | |
bool | getRadioCheckedState(string $name, mixed $value, bool $checked) Get the check state for a radio input. | |
bool | missingOldAndModel(string $name) Determine if old input or model input exists for a key. | |
string | reset(string $value, array $attributes = array()) Create a HTML reset input element. | |
string | image(string $url, string $name = null, array $attributes = array()) Create a HTML image input element. | |
string | submit(string $value = null, array $options = array()) Create a submit button element. | |
string | button(string $value = null, array $options = array()) Create a button element. | |
string | getMethod(string $method) Parse the form action method. | |
string | getAction(array $options) Get the form action from the options. | |
string | getUrlAction(array|string $options) Get the action for a "url" option. | |
string | getRouteAction(array|string $options) Get the action for a "route" option. | |
string | getControllerAction(array|string $options) Get the action for an "action" option. | |
string | getAppendage(string $method) Get the form appendage for the given method. | |
string | getIdAttribute(string $name, array $attributes) Get the ID attribute for a field name. | |
string | getValueAttribute(string $name, string $value = null) Get the value that should be assigned to the field. | |
string | getModelValueAttribute(string $name) Get the model value that should be assigned to the field. | |
string | old(string $name) Get a value from the session's old input. | |
bool | oldInputIsEmpty() Determine if the old input is empty. | |
string | transformKey(string $key) Transform key from array to dot syntax. | |
Store | getSessionStore() Get the session store implementation. | |
$this | setSessionStore(Store $session) Set the session store implementation. |
Details
static void macro(string $name, callable $macro)
Register a custom macro.
static boolean hasMacro(string $name)
Checks if macro is registered
static mixed __callStatic(string $method, array $parameters)
Dynamically handle calls to the class.
mixed __call(string $method, array $parameters)
Dynamically handle calls to the class.
void __construct(HtmlBuilder $html, UrlGenerator $url, $csrfToken)
Create a new form builder instance.
string open(array $options = array())
Open up a new HTML form.
string model(mixed $model, array $options = array())
Create a new model based form builder.
void setModel(mixed $model)
Set the model instance on the form builder.
string close()
Close the current form.
string token()
Generate a hidden field with the current CSRF token.
string label(string $name, string $value = null, array $options = array())
Create a form label element.
protected string formatLabel(string $name, string|null $value)
Format the label value.
string input(string $type, string $name, string $value = null, array $options = array())
Create a form input field.
string text(string $name, string $value = null, array $options = array())
Create a text input field.
string password(string $name, array $options = array())
Create a password input field.
string hidden(string $name, string $value = null, array $options = array())
Create a hidden input field.
string email(string $name, string $value = null, array $options = array())
Create an e-mail input field.
string url(string $name, string $value = null, array $options = array())
Create a url input field.
string file(string $name, array $options = array())
Create a file input field.
string textarea(string $name, string $value = null, array $options = array())
Create a textarea input field.
protected array setTextAreaSize(array $options)
Set the text area size on the attributes.
protected array setQuickTextAreaSize(array $options)
Set the text area size using the quick "size" attribute.
string number(string $name, string|null $value = null, array $options = array())
Create a number input field.
string select(string $name, array $list = array(), string $selected = null, array $options = array())
Create a select box field.
string selectRange(string $name, string $begin, string $end, string $selected = null, array $options = array())
Create a select range field.
string selectYear()
Create a select year field.
string selectMonth(string $name, string $selected = null, array $options = array(), string $format = '%B')
Create a select month field.
string getSelectOption(string $display, string $value, string $selected)
Get the select option for the given value.
protected string optionGroup(array $list, string $label, string $selected)
Create an option group form element.
protected string option(string $display, string $value, string $selected)
Create a select element option.
protected string getSelectedValue(string $value, string $selected)
Determine if the value is selected.
string checkbox(string $name, mixed $value = 1, bool $checked = null, array $options = array())
Create a checkbox input field.
string radio(string $name, mixed $value = null, bool $checked = null, array $options = array())
Create a radio button input field.
protected string checkable(string $type, string $name, mixed $value, bool $checked, array $options)
Create a checkable input field.
protected bool getCheckedState(string $type, string $name, mixed $value, bool $checked)
Get the check state for a checkable input.
protected bool getCheckboxCheckedState(string $name, mixed $value, bool $checked)
Get the check state for a checkbox input.
protected bool getRadioCheckedState(string $name, mixed $value, bool $checked)
Get the check state for a radio input.
protected bool missingOldAndModel(string $name)
Determine if old input or model input exists for a key.
string reset(string $value, array $attributes = array())
Create a HTML reset input element.
string image(string $url, string $name = null, array $attributes = array())
Create a HTML image input element.
string submit(string $value = null, array $options = array())
Create a submit button element.
string button(string $value = null, array $options = array())
Create a button element.
protected string getMethod(string $method)
Parse the form action method.
protected string getAction(array $options)
Get the form action from the options.
protected string getUrlAction(array|string $options)
Get the action for a "url" option.
protected string getRouteAction(array|string $options)
Get the action for a "route" option.
protected string getControllerAction(array|string $options)
Get the action for an "action" option.
protected string getAppendage(string $method)
Get the form appendage for the given method.
string getIdAttribute(string $name, array $attributes)
Get the ID attribute for a field name.
string getValueAttribute(string $name, string $value = null)
Get the value that should be assigned to the field.
protected string getModelValueAttribute(string $name)
Get the model value that should be assigned to the field.
string old(string $name)
Get a value from the session's old input.
bool oldInputIsEmpty()
Determine if the old input is empty.
protected string transformKey(string $key)
Transform key from array to dot syntax.
Store getSessionStore()
Get the session store implementation.
$this setSessionStore(Store $session)
Set the session store implementation.
© Taylor Otwell
Licensed under the MIT License.
Laravel is a trademark of Taylor Otwell.
https://laravel.com/api/4.2/Illuminate/Html/FormBuilder.html