October\Rain\Html\FormBuilder

Source: ~/vendor/october/rain/src/Html/FormBuilder.php

Form builder

Protected properties

protected October\Rain\Html\HtmlBuilder $html

The HTML builder instance.

protected Illuminate\Routing\UrlGenerator $url

The URL generator instance.

protected string $csrfToken

The CSRF token used by the form builder.

protected Illuminate\Session\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 $reservedAjax

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 string $sessionKey

The session key used by the form builder.

protected static array $macros

The registered string macros.

Public methods

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

Dynamically handle calls to the class.

Parameters
  • string $method
  • array $parameters

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

Dynamically handle calls to the class.

Parameters
  • string $method
  • array $parameters

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

Create a new form builder instance.

Parameters

public string ajax(string $handler, array $options=array())

Helper for opening a form used for an AJAX call.

Parameters
  • string $handler - Request handler name, eg: onUpdate
  • array $options

public string button(string $value=NULL, array $options=array())

Create a button element.

Parameters
  • string $value
  • array $options

public string checkbox(string $name, mixed $value=1, bool $checked=NULL, array $options=array())

Create a checkbox input field.

Parameters
  • string $name
  • mixed $value
  • bool $checked
  • array $options

public string close()

Close the current form.

public string email(string $name, string $value=NULL, array $options=array())

Create an e-mail input field.

Parameters
  • string $name
  • string $value
  • array $options

public string file(string $name, array $options=array())

Create a file input field.

Parameters
  • string $name
  • array $options

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

Get the ID attribute for a field name.

Parameters
  • string $name
  • array $attributes

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

Get the select option for the given value.

Parameters
  • string $display
  • string $value
  • string $selected

public string getSessionKey()

Returns the active session key, used fr deferred bindings.

public Illuminate\Session\Store getSessionStore()

Get the session store implementation.

public string getValueAttribute(string $name, string $value=NULL)

Get the value that should be assigned to the field.

Parameters
  • string $name
  • string $value

public static bool hasMacro(string $name)

Checks if macro is registered.

Parameters
  • string $name

public string hidden(string $name, string $value=NULL, array $options=array())

Create a hidden input field.

Parameters
  • string $name
  • string $value
  • array $options

public string image(string $url, string $name=NULL, array $attributes=array())

Create a HTML image input element.

Parameters
  • string $url
  • string $name
  • array $attributes

public string input(string $type, string $name, string $value=NULL, array $options=array())

Create a form input field.

Parameters
  • string $type
  • string $name
  • string $value
  • array $options

public string label(string $name, string $value=NULL, array $options=array())

Create a form label element.

Parameters
  • string $name
  • string $value
  • array $options

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

Register a custom macro.

Parameters
  • string $name
  • object|callable $macro

public static void mixin(object $mixin)

Mix another object into the class.

Parameters
  • object $mixin

public string model(mixed $model, array $options=array())

Create a new model based form builder.

Parameters
  • mixed $model
  • array $options

public string old(string $name)

Get a value from the session's old input.

Parameters
  • string $name

public bool oldInputIsEmpty()

Determine if the old input is empty.

public string open(array $options=array())

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

Parameters
  • array $options

public string password(string $name, array $options=array())

Create a password input field.

Parameters
  • string $name
  • array $options

public string radio(string $name, mixed $value=NULL, bool $checked=NULL, array $options=array())

Create a radio button input field.

Parameters
  • string $name
  • mixed $value
  • bool $checked
  • array $options

public string reset(string $value, array $attributes=array())

Create a HTML reset input element.

Parameters
  • string $value
  • array $attributes

public string select(string $name, array $list=array(), string $selected=NULL, array $options=array())

Create a select box field with empty option support.

Parameters
  • string $name
  • array $list
  • string $selected
  • array $options

public string selectMonth(string $name, string $selected=NULL, array $options=array(), string $format='%B')

Create a select month field.

Parameters
  • string $name
  • string $selected
  • array $options
  • string $format

public string selectRange(string $name, string $begin, string $end, string $selected=NULL, array $options=array())

Create a select range field.

Parameters
  • string $name
  • string $begin
  • string $end
  • string $selected
  • array $options

public string selectYear()

Create a select year field.

public string sessionKey($sessionKey=NULL)

Returns a hidden HTML input, supplying the session key value.

Parameters
  • $sessionKey

public void setModel(mixed $model)

Set the model instance on the form builder.

Parameters
  • mixed $model

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

Set the session store implementation.

Parameters
  • Illuminate\Session\Store $session

public string submit(string $value=NULL, array $options=array())

Create a submit button element.

Parameters
  • string $value
  • array $options

public string text(string $name, string $value=NULL, array $options=array())

Create a text input field.

Parameters
  • string $name
  • string $value
  • array $options

public string textarea(string $name, string $value=NULL, array $options=array())

Create a textarea input field.

Parameters
  • string $name
  • string $value
  • array $options

public string token()

Generate a hidden field with the current CSRF token.

public string url(string $name, string $value=NULL, array $options=array())

Create a url input field.

Parameters
  • string $name
  • string $value
  • array $options

public string value(string $name, string $value=NULL)

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

Parameters
  • string $name
  • string $value

Protected methods

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

Create a checkable input field.

Parameters
  • string $type
  • string $name
  • mixed $value
  • bool $checked
  • array $options

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

Format the label value.

Parameters
  • string $name
  • string|null $value

protected string getAction(array $options)

Get the form action from the options.

Parameters
  • array $options

protected string getAppendage(string $method)

Get the form appendage for the given method.

Parameters
  • string $method

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

Get the check state for a checkbox input.

Parameters
  • string $name
  • mixed $value
  • bool $checked

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

Get the check state for a checkable input.

Parameters
  • string $type
  • string $name
  • mixed $value
  • bool $checked

protected string getControllerAction(array|string $options)

Get the action for an "action" option.

Parameters
  • array|string $options

protected string getMethod(string $method)

Parse the form action method.

Parameters
  • string $method

protected string getModelValueAttribute(string $name)

Get the model value that should be assigned to the field.

Parameters
  • string $name

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

Get the check state for a radio input.

Parameters
  • string $name
  • mixed $value
  • bool $checked

protected string getRouteAction(array|string $options)

Get the action for a "route" option.

Parameters
  • array|string $options

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

Determine if the value is selected.

Parameters
  • string $value
  • string $selected

protected string getUrlAction(array|string $options)

Get the action for a "url" option.

Parameters
  • array|string $options

protected bool missingOldAndModel(string $name)

Determine if old input or model input exists for a key.

Parameters
  • string $name

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

Create a select element option.

Parameters
  • string $display
  • string $value
  • string $selected

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

Create an option group form element.

Parameters
  • array $list
  • string $label
  • string $selected

protected string requestHandler($name=NULL)

Returns a hidden HTML input, supplying the session key value.

Parameters
  • $name

protected array setQuickTextAreaSize(array $options)

Set the text area size using the quick "size" attribute.

Parameters
  • array $options

protected array setTextAreaSize(array $options)

Set the text area size on the attributes.

Parameters
  • array $options

protected string transformKey(string $key)

Transform key from array to dot syntax.

Parameters
  • string $key