FormBuilder
class FormBuilder (View source)
Traits
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
Dynamically handle calls to the class.
Dynamically handle calls to the class.
Create a new form builder instance.
Open up a new HTML form.
Create a new model based form builder.
Set the model instance on the form builder.
Close the current form.
Generate a hidden field with the current CSRF token.
Create a form label element.
Format the label value.
Create a form input field.
Create a text input field.
Create a password input field.
Create a hidden input field.
Create an e-mail input field.
Create a url input field.
Create a file input field.
Create a textarea input field.
Set the text area size on the attributes.
Set the text area size using the quick "size" attribute.
Create a number input field.
Create a select box field.
Create a select range field.
Create a select year field.
Create a select month field.
Get the select option for the given value.
Create an option group form element.
Create a select element option.
Determine if the value is selected.
Create a checkbox input field.
Create a radio button input field.
Create a checkable input field.
Get the check state for a checkable input.
Get the check state for a checkbox input.
Get the check state for a radio input.
Determine if old input or model input exists for a key.
Create a HTML reset input element.
Create a HTML image input element.
Create a submit button element.
Create a button element.
Parse the form action method.
Get the form action from the options.
Get the action for a "url" option.
Get the action for a "route" option.
Get the action for an "action" option.
Get the form appendage for the given method.
Get the ID attribute for a field name.
Get the value that should be assigned to the field.
Get the model value that should be assigned to the field.
Get a value from the session's old input.
Determine if the old input is empty.
Transform key from array to dot syntax.
Get the session store implementation.
Details
static void
macro(string $name, callable $macro)
Register a custom macro.
static bool
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, string $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.