Zend Framework  3.0
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Fieldset Class Reference

Public Member Functions

 __construct ($name=null, $options=[])
 
 setOptions ($options)
 Set options for a fieldset.
 
 setFormFactory (Factory $factory)
 Compose a form factory to use when calling add() with a non-element/fieldset.
 
 getFormFactory ()
 Retrieve composed form factory.
 
 add ($elementOrFieldset, array $flags=[])
 Add an element or fieldset.
 
 has ($elementOrFieldset)
 Does the fieldset have an element/fieldset by the given name?
 
 get ($elementOrFieldset)
 Retrieve a named element or fieldset.
 
 remove ($elementOrFieldset)
 Remove a named element or fieldset.
 
 setPriority ($elementOrFieldset, $priority)
 Set/change the priority of an element or fieldset.
 
 getElements ()
 Retrieve all attached elements.
 
 getFieldsets ()
 Retrieve all attached fieldsets.
 
 setMessages ($messages)
 Set a hash of element names/messages to use when validation fails.
 
 getMessages ($elementName=null)
 Get validation error messages, if any.
 
 prepareElement (FormInterface $form)
 Ensures state is ready for use.
 
 populateValues ($data)
 Recursively populate values of attached elements and fieldsets.
 
 count ()
 Countable: return count of attached elements/fieldsets.
 
 getIterator ()
 IteratorAggregate: return internal iterator.
 
 setObject ($object)
 Set the object used by the hydrator.
 
 getObject ()
 Get the object used by the hydrator.
 
 setAllowedObjectBindingClass ($allowObjectBindingClass)
 Set the class or interface of objects that can be bound to this fieldset.
 
 allowedObjectBindingClass ()
 Get The class or interface of objects that can be bound to this fieldset.
 
 allowObjectBinding ($object)
 Checks if the object can be set in this fieldset.
 
 setHydrator (HydratorInterface $hydrator)
 Set the hydrator to use when binding an object to the element.
 
 getHydrator ()
 Get the hydrator used when binding an object to the fieldset.
 
 allowValueBinding ()
 Checks if this fieldset can bind data.
 
 bindValues (array $values=[])
 Bind values to the bound object.
 
 setUseAsBaseFieldset ($useAsBaseFieldset)
 Set if this fieldset is used as a base fieldset.
 
 useAsBaseFieldset ()
 Is this fieldset use as a base fieldset for a form ?
 
 __clone ()
 Make a deep clone of a fieldset.
 
- Public Member Functions inherited from Element
 __construct ($name=null, $options=[])
 
 init ()
 This function is automatically called when creating element with factory.
 
 setName ($name)
 Set value for name.
 
 getName ()
 Get value for name.
 
 setOptions ($options)
 Set options for an element.
 
 getOptions ()
 Get defined options.
 
 getOption ($option)
 Return the specified option.
 
 setOption ($key, $value)
 Set a single option for an element.
 
 setAttribute ($key, $value)
 Set a single element attribute.
 
 getAttribute ($key)
 Retrieve a single element attribute.
 
 removeAttribute ($key)
 Remove a single attribute.
 
 hasAttribute ($key)
 Does the element has a specific attribute ?
 
 setAttributes ($arrayOrTraversable)
 Set many attributes at once.
 
 getAttributes ()
 Retrieve all attributes at once.
 
 removeAttributes (array $keys)
 Remove many attributes at once.
 
 clearAttributes ()
 Clear all attributes.
 
 setValue ($value)
 Set the element value.
 
 getValue ()
 Retrieve the element value.
 
 setLabel ($label)
 Set the label used for this element.
 
 getLabel ()
 Retrieve the label used for this element.
 
 setLabelAttributes (array $labelAttributes)
 Set the attributes to use with the label.
 
 getLabelAttributes ()
 Get the attributes to use with the label.
 
 setLabelOptions ($arrayOrTraversable)
 Set many label options at once.
 
 getLabelOptions ()
 Get label specific options.
 
 clearLabelOptions ()
 Clear all label options.
 
 removeLabelOptions (array $keys)
 Remove many attributes at once.
 
 setLabelOption ($key, $value)
 Set a single label optionn.
 
 getLabelOption ($key)
 Retrieve a single label option.
 
 removeLabelOption ($key)
 Remove a single label option.
 
 hasLabelOption ($key)
 Does the element has a specific label option ?
 
 setMessages ($messages)
 Set a list of messages to report when validation fails.
 
 getMessages ()
 Get validation error messages, if any.
 

Protected Member Functions

 extract ()
 Extract values from the bound object.
 

Protected Attributes

 $factory
 
 $elements = []
 
 $fieldsets = []
 
 $messages = []
 
 $iterator
 
 $hydrator
 
 $object
 
 $useAsBaseFieldset = false
 
 $allowedObjectBindingClass
 
- Protected Attributes inherited from Element
 $attributes = []
 
 $label
 
 $labelAttributes = []
 
 $labelOptions = []
 
 $messages = []
 
 $options = []
 
 $value
 

Constructor & Destructor Documentation

__construct (   $name = null,
  $options = [] 
)
Parameters
null | int | string$nameOptional name for the element
array$optionsOptional options for the element

Member Function Documentation

__clone ( )

Make a deep clone of a fieldset.

Returns
void
add (   $elementOrFieldset,
array  $flags = [] 
)

Add an element or fieldset.

$flags could contain metadata such as the alias under which to register the element or fieldset, order in which to prioritize it, etc.

Todo:
Should we detect if the element/fieldset name conflicts?
Parameters
array | Traversable | ElementInterface$elementOrFieldset
array$flags
Returns
Fieldset|FieldsetInterface
Exceptions
Exception\InvalidArgumentException

Implements FieldsetInterface.

allowedObjectBindingClass ( )

Get The class or interface of objects that can be bound to this fieldset.

Returns
string
allowObjectBinding (   $object)

Checks if the object can be set in this fieldset.

Parameters
object$object
Returns
bool

Implements FieldsetInterface.

allowValueBinding ( )

Checks if this fieldset can bind data.

Returns
bool

Implements FieldsetInterface.

bindValues ( array  $values = [])

Bind values to the bound object.

Parameters
array$values
Returns
mixed|void

Implements FieldsetInterface.

count ( )

Countable: return count of attached elements/fieldsets.

Returns
int
extract ( )
protected

Extract values from the bound object.

Returns
array
get (   $elementOrFieldset)

Retrieve a named element or fieldset.

Parameters
string$elementOrFieldset
Returns
ElementInterface

Implements FieldsetInterface.

getElements ( )

Retrieve all attached elements.

Storage is an implementation detail of the concrete class.

Returns
array|Traversable

Implements FieldsetInterface.

getFieldsets ( )

Retrieve all attached fieldsets.

Storage is an implementation detail of the concrete class.

Returns
array|Traversable

Implements FieldsetInterface.

getFormFactory ( )

Retrieve composed form factory.

Lazy-loads one if none present.

Returns
Factory
getHydrator ( )

Get the hydrator used when binding an object to the fieldset.

If no hydrator is present and object implements HydratorAwareInterface, hydrator will be retrieved from the object.

Will lazy-load Hydrator if none is present.

Returns
HydratorInterface

Implements FieldsetInterface.

getIterator ( )

IteratorAggregate: return internal iterator.

Returns
PriorityList
getMessages (   $elementName = null)

Get validation error messages, if any.

Returns a hash of element names/messages for all elements failing validation, or, if $elementName is provided, messages for that element only.

Parameters
null | string$elementName
Returns
array|Traversable
Exceptions
Exception\InvalidArgumentException
getObject ( )

Get the object used by the hydrator.

Returns
mixed

Implements FieldsetInterface.

has (   $elementOrFieldset)

Does the fieldset have an element/fieldset by the given name?

Parameters
string$elementOrFieldset
Returns
bool

Implements FieldsetInterface.

populateValues (   $data)

Recursively populate values of attached elements and fieldsets.

Parameters
array | Traversable$data
Returns
void
Exceptions
Exception\InvalidArgumentException

Implements FieldsetInterface.

prepareElement ( FormInterface  $form)

Ensures state is ready for use.

Here, we append the name of the fieldsets to every elements in order to avoid name clashes if the same fieldset is used multiple times

Parameters
FormInterface$form
Returns
mixed|void

Implements ElementPrepareAwareInterface.

remove (   $elementOrFieldset)

Remove a named element or fieldset.

Parameters
string$elementOrFieldset
Returns
FieldsetInterface

Implements FieldsetInterface.

setAllowedObjectBindingClass (   $allowObjectBindingClass)

Set the class or interface of objects that can be bound to this fieldset.

Parameters
string$allowObjectBindingClass
setFormFactory ( Factory  $factory)

Compose a form factory to use when calling add() with a non-element/fieldset.

Parameters
Factory$factory
Returns
Form

Implements FormFactoryAwareInterface.

setHydrator ( HydratorInterface  $hydrator)

Set the hydrator to use when binding an object to the element.

Parameters
HydratorInterface$hydrator
Returns
FieldsetInterface

Implements FieldsetInterface.

setMessages (   $messages)

Set a hash of element names/messages to use when validation fails.

Parameters
array | Traversable$messages
Returns
Element|ElementInterface|FieldsetInterface
Exceptions
Exception\InvalidArgumentException

Implements ElementInterface.

setObject (   $object)

Set the object used by the hydrator.

Parameters
object$object
Returns
Fieldset|FieldsetInterface
Exceptions
Exception\InvalidArgumentException

Implements FieldsetInterface.

setOptions (   $options)

Set options for a fieldset.

Accepted options are:

  • use_as_base_fieldset: is this fieldset use as the base fieldset?
Parameters
array | Traversable$options
Returns
Element|ElementInterface
Exceptions
Exception\InvalidArgumentException

Implements ElementInterface.

setPriority (   $elementOrFieldset,
  $priority 
)

Set/change the priority of an element or fieldset.

Parameters
string$elementOrFieldset
int$priority
Returns
FieldsetInterface

Implements FieldsetInterface.

setUseAsBaseFieldset (   $useAsBaseFieldset)

Set if this fieldset is used as a base fieldset.

Parameters
bool$useAsBaseFieldset
Returns
Fieldset
useAsBaseFieldset ( )

Is this fieldset use as a base fieldset for a form ?

Returns
bool

Member Data Documentation

$elements = []
protected
$factory
protected
$fieldsets = []
protected
$hydrator
protected
$iterator
protected
$messages = []
protected
$object
protected
$useAsBaseFieldset = false
protected