October\Rain\Html\FormBuilder


Protected Properties

protected October\Rain\Html\HtmlBuilder $html

html builder instance

protected Illuminate\Routing\UrlGenerator $url

url generator instance.

protected string $csrfToken

csrfToken used by the form builder.

protected Illuminate\Session\Store $session

session store implementation.

protected mixed $model

model instance for the form.

protected array $labels

labels is an array of label names we've created.

protected array $reserved

reserved form open attributes.

protected array $reservedAjax

reservedAjax form open attributes.

protected array $spoofedMethods

spoofedMethods are form methods that should be spoofed, in uppercase.

protected array $skipValueTypes

skipValueTypes of inputs to not fill values on by default.

protected string $sessionKey

sessionKey used by the form builder.

protected static array $macros

The registered string macros.


Public Methods

public __call()

public __call(string $method, array $parameters): mixed 

Dynamically handle calls to the class.

public static __callStatic()

public static __callStatic(string $method, array $parameters): mixed 

Dynamically handle calls to the class.

public __construct()

public __construct(
    October\Rain\Html\HtmlBuilder $html,
    Illuminate\Routing\UrlGenerator $url,
    string $csrfToken,
    string $sessionKey
): void 

__construct a new form builder instance.

public ajax()

public ajax(string $handler, array $options = []): string 

ajax helper for opening a form used for an AJAX call.

public button()

public button(string $value = null, array $options = []): string 

button element.

public checkbox()

public checkbox(
    string $name,
    mixed $value = 1,
    bool $checked = null,
    array $options = []
): string 

checkbox input field.

public close()

public close(): string 

close the current form.

public email()

public email(
    string $name,
    string $value = null,
    array $options = []
): string 

email input field.

public file()

public file(string $name, array $options = []): string 

file input field.

public static flushMacros()

public static flushMacros(): void 

Flush the existing macros.

public getIdAttribute()

public getIdAttribute(string $name, array $attributes): string 

getIdAttribute for a field name.

public getSelectOption()

public getSelectOption(
    string $display,
    string $value,
    string $selected
): string 

getSelectOption for the given value.

public getSessionKey()

public getSessionKey(): string 

getSessionKey returns the active session key, used fr deferred bindings.

public getSessionStore()

public getSessionStore(): Illuminate\Session\Store 

getSessionStore implementation.

public getValueAttribute()

public getValueAttribute(string $name, string $value = null): string 

getValueAttribute that should be assigned to the field.

public static hasMacro()

public static hasMacro(string $name): bool 

Checks if macro is registered.

public hidden()

public hidden(
    string $name,
    string $value = null,
    array $options = []
): string 

hidden input field.

public image()

public image(
    string $url,
    string $name = null,
    array $attributes = []
): string 

image input element.

public input()

public input(
    string $type,
    string $name,
    string $value = null,
    array $options = []
): string 

input creates a form input field.

public label()

public label(
    string $name,
    string $value = null,
    array $options = []
): string 

label creates a form label element.

public static macro()

public static macro(string $name, object|callable $macro): void 

Register a custom macro.

public static mixin()

public static mixin(object $mixin, bool $replace = true): void 

Mix another object into the class.

public model()

public model(mixed $model, array $options = []): string 

model creates a new model based form builder.

public number()

public number(
    string $name,
    string $value = null,
    array $options = []
): string 

number input field.

public old()

public old(string $name): string 

old gets a value from the session's old input.

public oldInputIsEmpty()

public oldInputIsEmpty(): bool 

oldInputIsEmpty determines if the old input is empty.

public open()

public open(array $options = []): string 

open up a new HTML form and includes a session key.

public password()

public password(string $name, array $options = []): string 

password input field.

public radio()

public radio(
    string $name,
    mixed $value = null,
    bool $checked = null,
    array $options = []
): string 

radio button input field.

public reset()

public reset(string $value, array $attributes = []): string 

reset input element.

public select()

public select(
    string $name,
    array $list = [],
    string $selected = null,
    array $options = []
): string 

select box field with empty option support.

public selectMonth()

public selectMonth(
    string $name,
    string $selected = null,
    array $options = [],
    string $format = '%B'
): string 

selectMonth field.

public selectOptions()

public selectOptions(
    string $name,
    array $list = [],
    string $selected = null,
    array $options = []
): string 

selectOptions only renders the options inside a select.

public selectRange()

public selectRange(
    string $name,
    string $begin,
    string $end,
    string $selected = null,
    array $options = []
): string 

selectRange field.

public selectYear()

public selectYear(): string 

selectYear field.

public sessionKey()

public sessionKey($sessionKey = null): string 

sessionKey returns a hidden HTML input, supplying the session key value.

public setModel()

public setModel(mixed $model): void 

setModel instance on the form builder.

public setSessionStore()

public setSessionStore(Illuminate\Session\Store $session): $this 

setSessionStore implementation.

public submit()

public submit(string $value = null, array $options = []): string 

submit button element.

public text()

public text(
    string $name,
    string $value = null,
    array $options = []
): string 

text input field.

public textarea()

public textarea(
    string $name,
    string $value = null,
    array $options = []
): string 

textarea input field.

public token()

public token(): string 

token generates a hidden field with the current CSRF token.

public url()

public url(
    string $name,
    string $value = null,
    array $options = []
): string 

url input field.

public value()

public value(string $name, string $value = null): string 

value is a helper for getting form values. Tries to find the old value, then uses a postback/get value, then looks at the form model values.

Protected Methods

protected checkable()

protected checkable(
    string $type,
    string $name,
    mixed $value,
    bool $checked,
    array $options
): string 

checkable input field.

protected formatLabel()

protected formatLabel(string $name, string|null $value): string 

formatLabel value.

protected getAction()

protected getAction(array $options): string 

getAction gets the form action from the options.

protected getAppendage()

protected getAppendage(string $method): string 

getAppendage gets the form appendage for the given method.

protected getCheckboxCheckedState()

protected getCheckboxCheckedState(
    string $name,
    mixed $value,
    bool $checked
): bool 

getCheckboxCheckedState for a checkbox input.

protected getCheckedState()

protected getCheckedState(
    string $type,
    string $name,
    mixed $value,
    bool $checked
): bool 

getCheckedState for a checkable input.

protected getControllerAction()

protected getControllerAction(array|string $options): string 

getControllerAction gets the action for an "action" option.

protected getMethod()

protected getMethod(string $method): string 

getMethod parses the form action method.

protected getModelValueAttribute()

protected getModelValueAttribute(string $name): string 

getModelValueAttribute that should be assigned to the field.

protected getRadioCheckedState()

protected getRadioCheckedState(
    string $name,
    mixed $value,
    bool $checked
): bool 

getRadioCheckedState for a radio input.

protected getRouteAction()

protected getRouteAction(array|string $options): string 

getRouteAction gets the action for a "route" option.

protected getSelectedValue()

protected getSelectedValue(string $value, string $selected): string 

getSelectedValue determines if the value is selected.

protected getUrlAction()

protected getUrlAction(array|string $options): string 

getUrlAction gets the action for a "url" option.

protected missingOldAndModel()

protected missingOldAndModel(string $name): bool 

missingOldAndModel determines if old input or model input exists for a key.

protected option()

protected option(
    string $display,
    string $value,
    string $selected
): string 

option for a select element option.

protected optionGroup()

protected optionGroup(
    array $list,
    string $label,
    string $selected
): string 

optionGroup form element.

protected requestHandler()

protected requestHandler($name = null): string 

requestHandler returns a hidden HTML input, supplying the session key value.

protected setQuickTextAreaSize()

protected setQuickTextAreaSize(array $options): array 

setQuickTextAreaSize using the quick "size" attribute.

protected setTextAreaSize()

protected setTextAreaSize(array $options): array 

setTextAreaSize on the attributes.

protected transformKey()

protected transformKey(string $key): string 

transformKey from array to dot syntax.