Fuel Documentation

Form Class

The Form class can both be used to create individual form elements or to create a full form along with validation, the latter is done in combination with the Fieldset class.

Create individual form elements

open($attributes = array(), $hidden = array())

Create a form open tag.

Static Yes
Parameters
Param Default Description
$attributes
array()
Either a string which will be the action attribute or an array of settings, if action isn't given it will use the current Uri. The attribute's values will be used as html tag properties.
$hidden
array()
An associative array of fieldnames and their values, will all be set as hidden fields.
Returns string
Example
// returns <form action="http://mydomain.com/uri/to/form" accept-charset="utf-8" method="post">
echo Form::open('uri/to/form');

// returns <form action="http://google.com/" accept-charset="utf-8" method="get">
echo Form::open(array('action' => 'http://google.com/', 'method' => 'get'));

close()

Create a form close tag.

Static Yes
Parameters (none)
Returns string
Example
// returns </form>
echo Form::close();

input($field, $value = null, $attributes = array())

Creates an html input element. It can be set using the fieldname, it's value and tag attributes or all in one attribute for the first arguement.

Static Yes
Parameters
Param Default Description
$field Required Either a string for the fieldname or an array of tag attributes.
$value
null
Field value, will be ignored when the first param is an array.
$attributes
array()
These will be used as html tag properties.
Returns string
Example
echo Form::input('name', 'value', array('style' => 'border: 2px;'));
// more to be added

hidden($field, $value = null, $attributes = array())

This is an alias for Form::input() that automaticly sets the type attribute to 'hidden'.

password($field, $value = null, $attributes = array())

This is an alias for Form::input() that automaticly sets the type attribute to 'password'.

radio($field, $value = null, $attributes = array())

This is an alias for Form::input() that automaticly sets the type attribute to 'radio'.

checkbox($field, $value = null, $attributes = array())

This is an alias for Form::input() that automaticly sets the type attribute to 'checkbox'.

button($field, $value = null, $attributes = array())

This is an alias for Form::input() that automaticly sets the type attribute to 'button'.

reset($field, $value = null, $attributes = array())

This is an alias for Form::input() that automaticly sets the type attribute to 'reset'.

submit($field, $value = null, $attributes = array())

This is an alias for Form::input() that automaticly sets the type attribute to 'submit'.

textarea($field, $value = null, $attributes = array())

Creates an html textarea element. It can be set using the fieldname, it's value and tag attributes or all in one attribute for the first arguement.

Static Yes
Parameters
Param Default Description
$field Required Either a string for the fieldname or an array of tag attributes.
$value
null
Field value, will be ignored when the first param is an array.
$attributes
array()
These will be used as html tag properties.
Returns string
Example
echo Form::textarea('description', 'enter here', array('rows' => 6, 'cols' => 8));
// more to be added

select($field, $values = null, $options = array(), $attributes = array())

Creates an html select element. It can be set using the fieldname, it's selected value(s), it's options and tag attributes or all in one attribute for the first arguement.

Static Yes
Parameters
Param Default Description
$field Required Either a string for the fieldname or an array of tag attributes.
$values
null
Field value or array of values when multiselect, will be ignored when the first param is an array.
$options
array()
Associative array of value=>label pairs, may also contain option groups as opt_name=>array() where the array contains it's set of value=>label pairs.
$attributes
array()
These will be used as html tag properties.
Returns string
Example
echo Form::select('country', 'none', array(
	'none' => 'None',
	'europe' => array(
		'uk' => 'United Kingdom',
		'nl' => 'Netherlands'
	),
	'us' => 'United States'
));
// more to be added

label($label, $id = null, $attributes = array())

Creates an html label element. It can be set using label, the id it's for and tag attributes or all in one attribute for the first arguement.

Static Yes
Parameters
Param Default Description
$label Required Either a string for the label or an array of tag attributes.
$id
null
The field's id this label belongs to.
$attributes
array()
These will be used as html tag properties.
Returns string
Example
echo Form::label('Username', 'username');
// more to be added

Create forms in an OOP way using fieldsets

Not yet documented.