PHP Class Collective\Html\FormBuilder

Inheritance: use trait Illuminate\Support\Traits\Macroable
Afficher le fichier Open project: laravelcollective/html Class Usage Examples

Protected Properties

Свойство Type Description
$csrfToken string The CSRF token used by the form builder.
$html HtmlBuilder The HTML builder instance.
$labels array An array of label names we've created.
$model mixed The current model instance for the form.
$reserved array The reserved form open attributes.
$session Illuminate\Session\SessionInterface The session store implementation.
$skipValueTypes array The types of inputs to not fill values on by default.
$spoofedMethods array The form methods that should be spoofed, in uppercase.
$url Illuminate\Contracts\Routing\UrlGenerator The URL generator instance.
$view Illuminate\Contracts\View\Factory The View factory instance.

Méthodes publiques

Méthode Description
__call ( string $method, array $parameters ) : Illuminate\Contracts\View\View | mixed Dynamically handle calls to the class.
__construct ( HtmlBuilder $html, Illuminate\Contracts\Routing\UrlGenerator $url, Illuminate\Contracts\View\Factory $view, string $csrfToken ) Create a new form builder instance.
button ( string $value = null, array $options = [] ) : Illuminate\Support\HtmlString Create a button element.
checkbox ( string $name, mixed $value = 1, boolean $checked = null, array $options = [] ) : Illuminate\Support\HtmlString Create a checkbox input field.
close ( ) : string Close the current form.
color ( string $name, string $value = null, array $options = [] ) : Illuminate\Support\HtmlString Create a color input field.
componentCall ( )
date ( string $name, string $value = null, array $options = [] ) : Illuminate\Support\HtmlString Create a date input field.
datetime ( string $name, string $value = null, array $options = [] ) : Illuminate\Support\HtmlString Create a datetime input field.
datetimeLocal ( string $name, string $value = null, array $options = [] ) : Illuminate\Support\HtmlString Create a datetime-local input field.
email ( string $name, string $value = null, array $options = [] ) : Illuminate\Support\HtmlString Create an e-mail input field.
file ( string $name, array $options = [] ) : Illuminate\Support\HtmlString Create a file input field.
getIdAttribute ( string $name, array $attributes ) : string Get the ID attribute for a field name.
getSelectOption ( string $display, string $value, string $selected ) : Illuminate\Support\HtmlString Get the select option for the given value.
getSessionStore ( ) : Illuminate\Session\SessionInterface Get the session store implementation.
getValueAttribute ( string $name, string $value = null ) : mixed Get the value that should be assigned to the field.
hidden ( string $name, string $value = null, array $options = [] ) : Illuminate\Support\HtmlString Create a hidden input field.
image ( string $url, string $name = null, array $attributes = [] ) : Illuminate\Support\HtmlString Create a HTML image input element.
input ( string $type, string $name, string $value = null, array $options = [] ) : Illuminate\Support\HtmlString Create a form input field.
label ( string $name, string $value = null, array $options = [], boolean $escape_html = true ) : Illuminate\Support\HtmlString Create a form label element.
macroCall ( )
model ( mixed $model, array $options = [] ) : Illuminate\Support\HtmlString Create a new model based form builder.
number ( string $name, string $value = null, array $options = [] ) : Illuminate\Support\HtmlString Create a number input field.
old ( string $name ) : mixed Get a value from the session's old input.
oldInputIsEmpty ( ) : boolean Determine if the old input is empty.
open ( array $options = [] ) : Illuminate\Support\HtmlString Open up a new HTML form.
password ( string $name, array $options = [] ) : Illuminate\Support\HtmlString Create a password input field.
radio ( string $name, mixed $value = null, boolean $checked = null, array $options = [] ) : Illuminate\Support\HtmlString Create a radio button input field.
reset ( string $value, array $attributes = [] ) : Illuminate\Support\HtmlString Create a HTML reset input element.
select ( string $name, array $list = [], string $selected = null, array $options = [] ) : Illuminate\Support\HtmlString Create a select box field.
selectMonth ( string $name, string $selected = null, array $options = [], string $format = '%B' ) : Illuminate\Support\HtmlString Create a select month field.
selectRange ( string $name, string $begin, string $end, string $selected = null, array $options = [] ) : Illuminate\Support\HtmlString Create a select range field.
selectYear ( ) : mixed Create a select year field.
setModel ( mixed $model ) : void Set the model instance on the form builder.
setSessionStore ( Illuminate\Session\SessionInterface $session ) Set the session store implementation.
submit ( string $value = null, array $options = [] ) : Illuminate\Support\HtmlString Create a submit button element.
tel ( string $name, string $value = null, array $options = [] ) : Illuminate\Support\HtmlString Create a tel input field.
text ( string $name, string $value = null, array $options = [] ) : Illuminate\Support\HtmlString Create a text input field.
textarea ( string $name, string $value = null, array $options = [] ) : Illuminate\Support\HtmlString Create a textarea input field.
time ( string $name, string $value = null, array $options = [] ) : Illuminate\Support\HtmlString Create a time input field.
token ( ) : string Generate a hidden field with the current CSRF token.
url ( string $name, string $value = null, array $options = [] ) : Illuminate\Support\HtmlString Create a url input field.

Méthodes protégées

Méthode Description
checkable ( string $type, string $name, mixed $value, boolean $checked, array $options ) : Illuminate\Support\HtmlString Create a checkable input field.
formatLabel ( string $name, string | null $value ) : string Format the label value.
getAction ( array $options ) : string Get the form action from the options.
getAppendage ( string $method ) : string Get the form appendage for the given method.
getCheckboxCheckedState ( string $name, mixed $value, boolean $checked ) : boolean Get the check state for a checkbox input.
getCheckedState ( string $type, string $name, mixed $value, boolean $checked ) : boolean Get the check state for a checkable input.
getControllerAction ( array | string $options ) : string Get the action for an "action" option.
getMethod ( string $method ) : string Parse the form action method.
getModelValueAttribute ( string $name ) : mixed Get the model value that should be assigned to the field.
getRadioCheckedState ( string $name, mixed $value, boolean $checked ) : boolean Get the check state for a radio input.
getRouteAction ( array | string $options ) : string Get the action for a "route" option.
getSelectedValue ( string $value, string $selected ) : null | string Determine if the value is selected.
getUrlAction ( array | string $options ) : string Get the action for a "url" option.
missingOldAndModel ( string $name ) : boolean Determine if old input or model input exists for a key.
option ( string $display, string $value, string $selected ) : Illuminate\Support\HtmlString Create a select element option.
optionGroup ( array $list, string $label, string $selected ) : Illuminate\Support\HtmlString Create an option group form element.
placeholderOption ( $display, $selected ) : Illuminate\Support\HtmlString Create a placeholder select element option.
setQuickTextAreaSize ( array $options ) : array Set the text area size using the quick "size" attribute.
setTextAreaSize ( array $options ) : array Set the text area size on the attributes.
toHtmlString ( $html ) : Illuminate\Support\HtmlString Transform the string to an Html serializable object
transformKey ( string $key ) : mixed Transform key from array to dot syntax.

Method Details

__call() public méthode

Dynamically handle calls to the class.
public __call ( string $method, array $parameters ) : Illuminate\Contracts\View\View | mixed
$method string
$parameters array
Résultat Illuminate\Contracts\View\View | mixed

__construct() public méthode

Create a new form builder instance.
public __construct ( HtmlBuilder $html, Illuminate\Contracts\Routing\UrlGenerator $url, Illuminate\Contracts\View\Factory $view, string $csrfToken )
$html HtmlBuilder
$url Illuminate\Contracts\Routing\UrlGenerator
$view Illuminate\Contracts\View\Factory
$csrfToken string

button() public méthode

Create a button element.
public button ( string $value = null, array $options = [] ) : Illuminate\Support\HtmlString
$value string
$options array
Résultat Illuminate\Support\HtmlString

checkable() protected méthode

Create a checkable input field.
protected checkable ( string $type, string $name, mixed $value, boolean $checked, array $options ) : Illuminate\Support\HtmlString
$type string
$name string
$value mixed
$checked boolean
$options array
Résultat Illuminate\Support\HtmlString

checkbox() public méthode

Create a checkbox input field.
public checkbox ( string $name, mixed $value = 1, boolean $checked = null, array $options = [] ) : Illuminate\Support\HtmlString
$name string
$value mixed
$checked boolean
$options array
Résultat Illuminate\Support\HtmlString

close() public méthode

Close the current form.
public close ( ) : string
Résultat string

color() public méthode

Create a color input field.
public color ( string $name, string $value = null, array $options = [] ) : Illuminate\Support\HtmlString
$name string
$value string
$options array
Résultat Illuminate\Support\HtmlString

componentCall() public méthode

public componentCall ( )

date() public méthode

Create a date input field.
public date ( string $name, string $value = null, array $options = [] ) : Illuminate\Support\HtmlString
$name string
$value string
$options array
Résultat Illuminate\Support\HtmlString

datetime() public méthode

Create a datetime input field.
public datetime ( string $name, string $value = null, array $options = [] ) : Illuminate\Support\HtmlString
$name string
$value string
$options array
Résultat Illuminate\Support\HtmlString

datetimeLocal() public méthode

Create a datetime-local input field.
public datetimeLocal ( string $name, string $value = null, array $options = [] ) : Illuminate\Support\HtmlString
$name string
$value string
$options array
Résultat Illuminate\Support\HtmlString

email() public méthode

Create an e-mail input field.
public email ( string $name, string $value = null, array $options = [] ) : Illuminate\Support\HtmlString
$name string
$value string
$options array
Résultat Illuminate\Support\HtmlString

file() public méthode

Create a file input field.
public file ( string $name, array $options = [] ) : Illuminate\Support\HtmlString
$name string
$options array
Résultat Illuminate\Support\HtmlString

formatLabel() protected méthode

Format the label value.
protected formatLabel ( string $name, string | null $value ) : string
$name string
$value string | null
Résultat string

getAction() protected méthode

Get the form action from the options.
protected getAction ( array $options ) : string
$options array
Résultat string

getAppendage() protected méthode

Get the form appendage for the given method.
protected getAppendage ( string $method ) : string
$method string
Résultat string

getCheckboxCheckedState() protected méthode

Get the check state for a checkbox input.
protected getCheckboxCheckedState ( string $name, mixed $value, boolean $checked ) : boolean
$name string
$value mixed
$checked boolean
Résultat boolean

getCheckedState() protected méthode

Get the check state for a checkable input.
protected getCheckedState ( string $type, string $name, mixed $value, boolean $checked ) : boolean
$type string
$name string
$value mixed
$checked boolean
Résultat boolean

getControllerAction() protected méthode

Get the action for an "action" option.
protected getControllerAction ( array | string $options ) : string
$options array | string
Résultat string

getIdAttribute() public méthode

Get the ID attribute for a field name.
public getIdAttribute ( string $name, array $attributes ) : string
$name string
$attributes array
Résultat string

getMethod() protected méthode

Parse the form action method.
protected getMethod ( string $method ) : string
$method string
Résultat string

getModelValueAttribute() protected méthode

Get the model value that should be assigned to the field.
protected getModelValueAttribute ( string $name ) : mixed
$name string
Résultat mixed

getRadioCheckedState() protected méthode

Get the check state for a radio input.
protected getRadioCheckedState ( string $name, mixed $value, boolean $checked ) : boolean
$name string
$value mixed
$checked boolean
Résultat boolean

getRouteAction() protected méthode

Get the action for a "route" option.
protected getRouteAction ( array | string $options ) : string
$options array | string
Résultat string

getSelectOption() public méthode

Get the select option for the given value.
public getSelectOption ( string $display, string $value, string $selected ) : Illuminate\Support\HtmlString
$display string
$value string
$selected string
Résultat Illuminate\Support\HtmlString

getSelectedValue() protected méthode

Determine if the value is selected.
protected getSelectedValue ( string $value, string $selected ) : null | string
$value string
$selected string
Résultat null | string

getSessionStore() public méthode

Get the session store implementation.
public getSessionStore ( ) : Illuminate\Session\SessionInterface
Résultat Illuminate\Session\SessionInterface $session

getUrlAction() protected méthode

Get the action for a "url" option.
protected getUrlAction ( array | string $options ) : string
$options array | string
Résultat string

getValueAttribute() public méthode

Get the value that should be assigned to the field.
public getValueAttribute ( string $name, string $value = null ) : mixed
$name string
$value string
Résultat mixed

hidden() public méthode

Create a hidden input field.
public hidden ( string $name, string $value = null, array $options = [] ) : Illuminate\Support\HtmlString
$name string
$value string
$options array
Résultat Illuminate\Support\HtmlString

image() public méthode

Create a HTML image input element.
public image ( string $url, string $name = null, array $attributes = [] ) : Illuminate\Support\HtmlString
$url string
$name string
$attributes array
Résultat Illuminate\Support\HtmlString

input() public méthode

Create a form input field.
public input ( string $type, string $name, string $value = null, array $options = [] ) : Illuminate\Support\HtmlString
$type string
$name string
$value string
$options array
Résultat Illuminate\Support\HtmlString

label() public méthode

Create a form label element.
public label ( string $name, string $value = null, array $options = [], boolean $escape_html = true ) : Illuminate\Support\HtmlString
$name string
$value string
$options array
$escape_html boolean
Résultat Illuminate\Support\HtmlString

macroCall() public méthode

public macroCall ( )

missingOldAndModel() protected méthode

Determine if old input or model input exists for a key.
protected missingOldAndModel ( string $name ) : boolean
$name string
Résultat boolean

model() public méthode

Create a new model based form builder.
public model ( mixed $model, array $options = [] ) : Illuminate\Support\HtmlString
$model mixed
$options array
Résultat Illuminate\Support\HtmlString

number() public méthode

Create a number input field.
public number ( string $name, string $value = null, array $options = [] ) : Illuminate\Support\HtmlString
$name string
$value string
$options array
Résultat Illuminate\Support\HtmlString

old() public méthode

Get a value from the session's old input.
public old ( string $name ) : mixed
$name string
Résultat mixed

oldInputIsEmpty() public méthode

Determine if the old input is empty.
public oldInputIsEmpty ( ) : boolean
Résultat boolean

open() public méthode

Open up a new HTML form.
public open ( array $options = [] ) : Illuminate\Support\HtmlString
$options array
Résultat Illuminate\Support\HtmlString

option() protected méthode

Create a select element option.
protected option ( string $display, string $value, string $selected ) : Illuminate\Support\HtmlString
$display string
$value string
$selected string
Résultat Illuminate\Support\HtmlString

optionGroup() protected méthode

Create an option group form element.
protected optionGroup ( array $list, string $label, string $selected ) : Illuminate\Support\HtmlString
$list array
$label string
$selected string
Résultat Illuminate\Support\HtmlString

password() public méthode

Create a password input field.
public password ( string $name, array $options = [] ) : Illuminate\Support\HtmlString
$name string
$options array
Résultat Illuminate\Support\HtmlString

placeholderOption() protected méthode

Create a placeholder select element option.
protected placeholderOption ( $display, $selected ) : Illuminate\Support\HtmlString
$display
$selected
Résultat Illuminate\Support\HtmlString

radio() public méthode

Create a radio button input field.
public radio ( string $name, mixed $value = null, boolean $checked = null, array $options = [] ) : Illuminate\Support\HtmlString
$name string
$value mixed
$checked boolean
$options array
Résultat Illuminate\Support\HtmlString

reset() public méthode

Create a HTML reset input element.
public reset ( string $value, array $attributes = [] ) : Illuminate\Support\HtmlString
$value string
$attributes array
Résultat Illuminate\Support\HtmlString

select() public méthode

Create a select box field.
public select ( string $name, array $list = [], string $selected = null, array $options = [] ) : Illuminate\Support\HtmlString
$name string
$list array
$selected string
$options array
Résultat Illuminate\Support\HtmlString

selectMonth() public méthode

Create a select month field.
public selectMonth ( string $name, string $selected = null, array $options = [], string $format = '%B' ) : Illuminate\Support\HtmlString
$name string
$selected string
$options array
$format string
Résultat Illuminate\Support\HtmlString

selectRange() public méthode

Create a select range field.
public selectRange ( string $name, string $begin, string $end, string $selected = null, array $options = [] ) : Illuminate\Support\HtmlString
$name string
$begin string
$end string
$selected string
$options array
Résultat Illuminate\Support\HtmlString

selectYear() public méthode

Create a select year field.
public selectYear ( ) : mixed
Résultat mixed

setModel() public méthode

Set the model instance on the form builder.
public setModel ( mixed $model ) : void
$model mixed
Résultat void

setQuickTextAreaSize() protected méthode

Set the text area size using the quick "size" attribute.
protected setQuickTextAreaSize ( array $options ) : array
$options array
Résultat array

setSessionStore() public méthode

Set the session store implementation.
public setSessionStore ( Illuminate\Session\SessionInterface $session )
$session Illuminate\Session\SessionInterface

setTextAreaSize() protected méthode

Set the text area size on the attributes.
protected setTextAreaSize ( array $options ) : array
$options array
Résultat array

submit() public méthode

Create a submit button element.
public submit ( string $value = null, array $options = [] ) : Illuminate\Support\HtmlString
$value string
$options array
Résultat Illuminate\Support\HtmlString

tel() public méthode

Create a tel input field.
public tel ( string $name, string $value = null, array $options = [] ) : Illuminate\Support\HtmlString
$name string
$value string
$options array
Résultat Illuminate\Support\HtmlString

text() public méthode

Create a text input field.
public text ( string $name, string $value = null, array $options = [] ) : Illuminate\Support\HtmlString
$name string
$value string
$options array
Résultat Illuminate\Support\HtmlString

textarea() public méthode

Create a textarea input field.
public textarea ( string $name, string $value = null, array $options = [] ) : Illuminate\Support\HtmlString
$name string
$value string
$options array
Résultat Illuminate\Support\HtmlString

time() public méthode

Create a time input field.
public time ( string $name, string $value = null, array $options = [] ) : Illuminate\Support\HtmlString
$name string
$value string
$options array
Résultat Illuminate\Support\HtmlString

toHtmlString() protected méthode

Transform the string to an Html serializable object
protected toHtmlString ( $html ) : Illuminate\Support\HtmlString
$html
Résultat Illuminate\Support\HtmlString

token() public méthode

Generate a hidden field with the current CSRF token.
public token ( ) : string
Résultat string

transformKey() protected méthode

Transform key from array to dot syntax.
protected transformKey ( string $key ) : mixed
$key string
Résultat mixed

url() public méthode

Create a url input field.
public url ( string $name, string $value = null, array $options = [] ) : Illuminate\Support\HtmlString
$name string
$value string
$options array
Résultat Illuminate\Support\HtmlString

Property Details

$csrfToken protected_oe property

The CSRF token used by the form builder.
protected string $csrfToken
Résultat string

$html protected_oe property

The HTML builder instance.
protected HtmlBuilder,Collective\Html $html
Résultat HtmlBuilder

$labels protected_oe property

An array of label names we've created.
protected array $labels
Résultat array

$model protected_oe property

The current model instance for the form.
protected mixed $model
Résultat mixed

$reserved protected_oe property

The reserved form open attributes.
protected array $reserved
Résultat array

$session protected_oe property

The session store implementation.
protected SessionInterface,Illuminate\Session $session
Résultat Illuminate\Session\SessionInterface

$skipValueTypes protected_oe property

The types of inputs to not fill values on by default.
protected array $skipValueTypes
Résultat array

$spoofedMethods protected_oe property

The form methods that should be spoofed, in uppercase.
protected array $spoofedMethods
Résultat array

$url protected_oe property

The URL generator instance.
protected UrlGenerator,Illuminate\Contracts\Routing $url
Résultat Illuminate\Contracts\Routing\UrlGenerator

$view protected_oe property

The View factory instance.
protected Factory,Illuminate\Contracts\View $view
Résultat Illuminate\Contracts\View\Factory