Fieldset Class

Define a set of fields that can be used to generate a form or to validate input.

package Fuel
category Core

 Methods

Object constructor

__construct($name, array $config) 

Parameters

$name

string

$config

array

Magic method toString that will build this as a form

__toString() : string

Returns

string

Factory for Fieldset_Field objects

add($name, $label, array $attributes, array $rules) : \Fuel\Core\Fieldset_Field

Parameters

$name

string

$label

string

$attributes

array

$rules

array

Returns

Add a new Fieldset_Field after an existing field in a Fieldset

add_after(string $name, string $label, array $attributes, array $rules, string $fieldname) : \Fuel\Core\Fieldset_Field

Parameters

$name

string

$label

string

$attributes

array

$rules

array

$fieldname

string

fieldname after which the new field is inserted in the fieldset

Returns

Add a new Fieldset_Field before an existing field in a Fieldset

add_before(string $name, string $label, array $attributes, array $rules, string $fieldname) : \Fuel\Core\Fieldset_Field

Parameters

$name

string

$label

string

$attributes

array

$rules

array

$fieldname

string

fieldname before which the new field is inserted in the fieldset

Returns

Add a model's fields The model must have a method "set_form_fields" that takes this Fieldset instance and adds fields to it.

add_model(string | Object $class, array | Object $instance, string $method) : \Fuel\Core\Fieldset

Parameters

$class

stringObject

either a full classname (including full namespace) or object instance

$instance

arrayObject

array or object that has the exactly same named properties to populate the fields

$method

string

method name to call on model for field fetching

Returns

\Fuel\Core\Fieldsetthis, to allow chaining

Build the fieldset HTML

build(mixed $action) : string

Parameters

$action

mixed

Returns

string

Return the child fieldset instances

children() : array

Returns

array

Delete a field instance

delete(string $name) : \Fuel\Core\Fieldset

Parameters

$name

string

field name or null to fetch an array of all

Returns

\Fuel\Core\Fieldsetthis fieldset, for chaining

Disable a field from being build

disable(mixed $name) : \Fuel\Core\Fieldset

Parameters

$name

mixed

Returns

\Fuel\Core\Fieldsetthis, to allow chaining

Enable a disabled field from being build

enable(mixed $name) : \Fuel\Core\Fieldset

Parameters

$name

mixed

Returns

\Fuel\Core\Fieldsetthis, to allow chaining

Alias for $this->validation()->error()

error(string $field) : \Fuel\Core\Validation_Error | array

Parameters

$field

string

Returns

Get Field instance

field(string | null $name, bool $flatten, bool $tabular_form) : \Fuel\Core\Fieldset_Field | false

Parameters

$name

stringnull

field name or null to fetch an array of all

$flatten

bool

whether to get the fields array or flattened array

$tabular_form

bool

whether to include tabular form fields in the flattened array

Returns

\Fuel\Core\Fieldset_Fieldfalsereturns false when field wasn't found

Create Fieldset object

forge(string $name, array $config) : \Fuel\Core\Fieldset

Parameters

$name

string

Identifier for this fieldset

$config

array

Configuration array

Returns

Get related Form instance or create it

form(bool | \Fuel\Core\Form $instance) : \Fuel\Core\Form

Parameters

$instance

bool\Fuel\Core\Form

Returns

Get a single or multiple config values by key

get_config(string | array $key, mixed $default) : mixed | array

Parameters

$key

stringarray

a single key or multiple in an array, empty to fetch all

$default

mixed

default output when config wasn't set

Returns

mixedarraya single config value or multiple in an array when $key input was an array

Get the fieldset name

get_name() : string

Returns

string

return the tabular form relation of this fieldset

get_tabular_form() : bool

Returns

bool

Alias for $this->validation()->input()

input(string $field) : mixed

Parameters

$field

string

Returns

mixed

Return a specific instance, or the default instance (is created if necessary)

instance(\Fuel\Core\Fieldset $instance) : \Fuel\Core\Fieldset

Parameters

Returns

Return parent Fieldset

parent() : \Fuel\Core\Fieldset

Populate the form's values using an input array or object

populate(array | object $input, bool $repopulate) : \Fuel\Core\Fieldset

Parameters

$input

arrayobject

$repopulate

bool

Returns

\Fuel\Core\Fieldsetthis, to allow chaining

Set all fields to the input from get or post (depends on the form method attribute)

repopulate() : \Fuel\Core\Fieldset

Returns

\Fuel\Core\Fieldsetthis, to allow chaining

Sets a config value on the fieldset

set_config(string $config, mixed $value) : \Fuel\Core\Fieldset

Parameters

$config

string

$value

mixed

Returns

\Fuel\Core\Fieldsetthis, to allow chaining

Set the tag to be used for this fieldset

set_fieldset_tag(string $tag) : \Fuel\Core\Fieldset

Parameters

$tag

string

Returns

\Fuel\Core\Fieldsetthis, to allow chaining

Set the parent Fieldset instance

set_parent(\Fuel\Core\Fieldset $fieldset) : \Fuel\Core\Fieldset

Parameters

$fieldset

\Fuel\Core\Fieldset

parent fieldset to which this belongs

Returns

Enable or disable the tabular form feature of this fieldset

set_tabular_form(string $model, string $relation, array $parent, int $blanks, \Fuel\Core\Pagination $pagination) : \Fuel\Core\Fieldset

Parameters

$model

string

Model on which to define the tabular form

$relation

string

Relation of the Model on the tabular form is modeled

$parent

array

Collection of Model objects from a many relation

$blanks

int

Number of empty rows to generate

$pagination

\Fuel\Core\Pagination

If the tabular form must be paginated, a pagination object

Returns

\Fuel\Core\Fieldsetthis, to allow chaining

Alias for $this->validation()->show_errors()

show_errors(array $config) : string

Parameters

$config

array

Returns

string

Alias for $this->validation()->validated()

validated(string $field) : mixed

Parameters

$field

string

Returns

mixed

Get related Validation instance or create it

validation(bool | \Fuel\Core\Validation $instance) : \Fuel\Core\Validation

Parameters

$instance

bool\Fuel\Core\Validation

Returns

Add a child Fieldset instance

add_child(\Fuel\Core\Fieldset $fieldset) : \Fuel\Core\Fieldset

Parameters

Returns

 Properties

 

$_instance

$_instance : \Fuel\Core\Fieldset

 

<p>contains references to all instantiations of Fieldset</p>

$_instances : array

 

<p>configuration array</p>

$config : array

 

<p>disabled fields array</p>

$disabled : array

 

<p>array of Fieldset_Field objects</p>

$fields : array

 

<p>instances that belong to this one</p>

$fieldset_children : array

 

<p>instance to which this instance belongs</p>

$fieldset_parent : \Fuel\Core\Fieldset

 

<p>tag used to wrap this instance</p>

$fieldset_tag : string

 

<p>instance of form</p>

$form : \Fuel\Core\Form

 

<p>instance id</p>

$name : string

 

<p>name of class providing the tabular form</p>

$tabular_form_model : string

 

<p>optional pagination object to paginate the rows in the tabular form</p>

$tabular_form_pagination : \Fuel\Core\Pagination

 

<p>name of the relation of the parent object this tabular form is modeled on</p>

$tabular_form_relation : string

 

<p>instance of validation</p>

$validation : \Fuel\Core\Validation