class FormBuilder (View source)

Traits

Methods

static  void
macro( string $name, callable $macro)

Register a custom macro.

static  boolean
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, $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.

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.

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.

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.

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.

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.

string
old( string $name)

Get a value from the session's old input.

bool
oldInputIsEmpty()

Determine if the old input is empty.

getSessionStore()

Get the session store implementation.

$this
setSessionStore( Store $session)

Set the session store implementation.

Details

static void macro( string $name, callable $macro)

Register a custom macro.

Parameters

string $name
callable $macro

Return Value

void

static boolean hasMacro( string $name)

Checks if macro is registered

Parameters

string $name

Return Value

boolean

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

Dynamically handle calls to the class.

Parameters

string $method
array $parameters

Return Value

mixed

Exceptions

BadMethodCallException

mixed __call( string $method, array $parameters)

Dynamically handle calls to the class.

Parameters

string $method
array $parameters

Return Value

mixed

Exceptions

BadMethodCallException

at line line 82
void __construct( HtmlBuilder $html, UrlGenerator $url, $csrfToken)

Create a new form builder instance.

Parameters

HtmlBuilder $html
UrlGenerator $url
$csrfToken

Return Value

void

at line line 95
string open( array $options = array())

Open up a new HTML form.

Parameters

array $options

Return Value

string

at line line 142
string model( mixed $model, array $options = array())

Create a new model based form builder.

Parameters

mixed $model
array $options

Return Value

string

at line line 155
void setModel( mixed $model)

Set the model instance on the form builder.

Parameters

mixed $model

Return Value

void

at line line 165
string close()

Close the current form.

Return Value

string

at line line 179
string token()

Generate a hidden field with the current CSRF token.

Return Value

string

at line line 192
string label( string $name, string $value = null, array $options = array())

Create a form label element.

Parameters

string $name
string $value
array $options

Return Value

string

at line line 224
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

Return Value

string

at line line 256
string text( string $name, string $value = null, array $options = array())

Create a text input field.

Parameters

string $name
string $value
array $options

Return Value

string

at line line 268
string password( string $name, array $options = array())

Create a password input field.

Parameters

string $name
array $options

Return Value

string

at line line 281
string hidden( string $name, string $value = null, array $options = array())

Create a hidden input field.

Parameters

string $name
string $value
array $options

Return Value

string

at line line 294
string email( string $name, string $value = null, array $options = array())

Create an e-mail input field.

Parameters

string $name
string $value
array $options

Return Value

string

at line line 307
string url( string $name, string $value = null, array $options = array())

Create a url input field.

Parameters

string $name
string $value
array $options

Return Value

string

at line line 319
string file( string $name, array $options = array())

Create a file input field.

Parameters

string $name
array $options

Return Value

string

at line line 332
string textarea( string $name, string $value = null, array $options = array())

Create a textarea input field.

Parameters

string $name
string $value
array $options

Return Value

string

at line line 399
string number( string $name, string|null $value = null, array $options = array())

Create a number input field.

Parameters

string $name
string|null $value
array $options

Return Value

string

at line line 413
string select( string $name, array $list = array(), string $selected = null, array $options = array())

Create a select box field.

Parameters

string $name
array $list
string $selected
array $options

Return Value

string

at line line 454
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

Return Value

string

at line line 471
string selectYear()

Create a select year field.

Return Value

string

at line line 485
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

Return Value

string

at line line 505
string getSelectOption( string $display, string $value, string $selected)

Get the select option for the given value.

Parameters

string $display
string $value
string $selected

Return Value

string

at line line 578
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

Return Value

string

at line line 592
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

Return Value

string

at line line 694
string reset( string $value, array $attributes = array())

Create a HTML reset input element.

Parameters

string $value
array $attributes

Return Value

string

at line line 707
string image( string $url, string $name = null, array $attributes = array())

Create a HTML image input element.

Parameters

string $url
string $name
array $attributes

Return Value

string

at line line 721
string submit( string $value = null, array $options = array())

Create a submit button element.

Parameters

string $value
array $options

Return Value

string

at line line 733
string button( string $value = null, array $options = array())

Create a button element.

Parameters

string $value
array $options

Return Value

string

at line line 872
string getIdAttribute( string $name, array $attributes)

Get the ID attribute for a field name.

Parameters

string $name
array $attributes

Return Value

string

at line line 892
string getValueAttribute( string $name, string $value = null)

Get the value that should be assigned to the field.

Parameters

string $name
string $value

Return Value

string

at line line 933
string old( string $name)

Get a value from the session's old input.

Parameters

string $name

Return Value

string

at line line 946
bool oldInputIsEmpty()

Determine if the old input is empty.

Return Value

bool

at line line 967
Store getSessionStore()

Get the session store implementation.

Return Value

Store $session

at line line 978
$this setSessionStore( Store $session)

Set the session store implementation.

Parameters

Store $session

Return Value

$this