FormBuilder
class FormBuilder
Traits
Properties
static protected array | $components | The registered components. |
from Componentable |
protected HtmlBuilder | $html | The HTML builder instance. |
|
protected UrlGenerator | $url | The URL generator instance. |
|
protected Factory | $view | The View factory instance. |
|
protected string | $csrfToken | The CSRF token used by the form builder. |
|
protected Session | $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 | $request | ||
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. |
|
protected null | $type | Input Type. |
Methods
Register a custom component.
Prepare the component data, while respecting provided defaults.
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 a search input field.
Create an e-mail input field.
Create a tel input field.
Create a number input field.
Create a date input field.
Create a datetime input field.
Create a datetime-local input field.
Create a time 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 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.
Create a placeholder 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 color input field.
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 value from current Request
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.
Transform the string to an Html serializable object
Get the session store implementation.
Set the session store implementation.
Details
in
Componentable at line 26
static void
component($name, $view, array $signature)
Register a custom component.
in
Componentable at line 38
static bool
hasComponent($name)
Check if a component is registered.
in
Componentable at line 51
protected HtmlString
renderComponent($name, array $arguments)
Render a custom component.
in
Componentable at line 69
protected array
getComponentData(array $signature, array $arguments)
Prepare the component data, while respecting provided defaults.
at line 1307
View|mixed
__call(string $method, array $parameters)
Dynamically handle calls to the class.
at line 112
__construct(HtmlBuilder $html, UrlGenerator $url, Factory $view, string $csrfToken, Request $request = null)
Create a new form builder instance.
at line 128
HtmlString
open(array $options = [])
Open up a new HTML form.
at line 175
HtmlString
model(mixed $model, array $options = [])
Create a new model based form builder.
at line 189
void
setModel(mixed $model)
Set the model instance on the form builder.
at line 199
string
close()
Close the current form.
at line 213
string
token()
Generate a hidden field with the current CSRF token.
at line 230
HtmlString
label(string $name, string $value = null, array $options = [], bool $escape_html = true)
Create a form label element.
at line 253
protected string
formatLabel(string $name, string|null $value)
Format the label value.
at line 268
HtmlString
input(string $type, string $name, string $value = null, array $options = [])
Create a form input field.
at line 304
HtmlString
text(string $name, string $value = null, array $options = [])
Create a text input field.
at line 317
HtmlString
password(string $name, array $options = [])
Create a password input field.
at line 331
HtmlString
hidden(string $name, string $value = null, array $options = [])
Create a hidden input field.
at line 345
HtmlString
search(string $name, string $value = null, array $options = [])
Create a search input field.
at line 359
HtmlString
email(string $name, string $value = null, array $options = [])
Create an e-mail input field.
at line 373
HtmlString
tel(string $name, string $value = null, array $options = [])
Create a tel input field.
at line 387
HtmlString
number(string $name, string $value = null, array $options = [])
Create a number input field.
at line 401
HtmlString
date(string $name, string $value = null, array $options = [])
Create a date input field.
at line 419
HtmlString
datetime(string $name, string $value = null, array $options = [])
Create a datetime input field.
at line 437
HtmlString
datetimeLocal(string $name, string $value = null, array $options = [])
Create a datetime-local input field.
at line 455
HtmlString
time(string $name, string $value = null, array $options = [])
Create a time input field.
at line 469
HtmlString
url(string $name, string $value = null, array $options = [])
Create a url input field.
at line 482
HtmlString
file(string $name, array $options = [])
Create a file input field.
at line 496
HtmlString
textarea(string $name, string $value = null, array $options = [])
Create a textarea input field.
at line 530
protected array
setTextAreaSize(array $options)
Set the text area size on the attributes.
at line 553
protected array
setQuickTextAreaSize(array $options)
Set the text area size using the quick "size" attribute.
at line 571
HtmlString
select(string $name, array $list = [], string $selected = null, array $selectAttributes = [], array $optionsAttributes = [])
Create a select box field.
at line 627
HtmlString
selectRange(string $name, string $begin, string $end, string $selected = null, array $options = [])
Create a select range field.
at line 639
mixed
selectYear()
Create a select year field.
at line 654
HtmlString
selectMonth(string $name, string $selected = null, array $options = [], string $format = '%B')
Create a select month field.
at line 675
HtmlString
getSelectOption(string $display, string $value, string $selected, array $attributes = [])
Get the select option for the given value.
at line 694
protected HtmlString
optionGroup(array $list, string $label, string $selected, array $attributes = [])
Create an option group form element.
at line 715
protected HtmlString
option(string $display, string $value, string $selected, array $attributes = [])
Create a select element option.
at line 732
protected HtmlString
placeholderOption($display, $selected)
Create a placeholder select element option.
at line 752
protected null|string
getSelectedValue(string $value, string $selected)
Determine if the value is selected.
at line 774
HtmlString
checkbox(string $name, mixed $value = 1, bool $checked = null, array $options = [])
Create a checkbox input field.
at line 789
HtmlString
radio(string $name, mixed $value = null, bool $checked = null, array $options = [])
Create a radio button input field.
at line 809
protected HtmlString
checkable(string $type, string $name, mixed $value, bool $checked, array $options)
Create a checkable input field.
at line 832
protected bool
getCheckedState(string $type, string $name, mixed $value, bool $checked)
Get the check state for a checkable input.
at line 855
protected bool
getCheckboxCheckedState(string $name, mixed $value, bool $checked)
Get the check state for a checkbox input.
at line 889
protected bool
getRadioCheckedState(string $name, mixed $value, bool $checked)
Get the check state for a radio input.
at line 907
protected bool
missingOldAndModel(string $name)
Determine if old input or model input exists for a key.
at line 920
HtmlString
reset(string $value, array $attributes = [])
Create a HTML reset input element.
at line 934
HtmlString
image(string $url, string $name = null, array $attributes = [])
Create a HTML image input element.
at line 950
HtmlString
color(string $name, string $value = null, array $options = [])
Create a color input field.
at line 963
HtmlString
submit(string $value = null, array $options = [])
Create a submit button element.
at line 976
HtmlString
button(string $value = null, array $options = [])
Create a button element.
at line 992
protected string
getMethod(string $method)
Parse the form action method.
at line 1006
protected string
getAction(array $options)
Get the form action from the options.
at line 1036
protected string
getUrlAction(array|string $options)
Get the action for a "url" option.
at line 1052
protected string
getRouteAction(array|string $options)
Get the action for a "route" option.
at line 1068
protected string
getControllerAction(array|string $options)
Get the action for an "action" option.
at line 1084
protected string
getAppendage(string $method)
Get the form appendage for the given method.
at line 1113
string
getIdAttribute(string $name, array $attributes)
Get the ID attribute for a field name.
at line 1132
mixed
getValueAttribute(string $name, string $value = null)
Get the value that should be assigned to the field.
at line 1179
protected array|null|string
request($name)
Get value from current Request
at line 1195
protected mixed
getModelValueAttribute(string $name)
Get the model value that should be assigned to the field.
at line 1213
mixed
old(string $name)
Get a value from the session's old input.
at line 1244
bool
oldInputIsEmpty()
Determine if the old input is empty.
at line 1256
protected mixed
transformKey(string $key)
Transform key from array to dot syntax.
at line 1268
protected HtmlString
toHtmlString($html)
Transform the string to an Html serializable object
at line 1278
Session
getSessionStore()
Get the session store implementation.
at line 1290
$this
setSessionStore(Session $session)
Set the session store implementation.