category Zend
package Zend_Form

 Methods

Create an element, fieldset, or form

create(array | \Traversable $spec) : \Zend\Form\ElementInterface

Introspects the 'type' key of the provided $spec, and determines what type is being requested; if none is provided, assumes the spec represents simply an element.

Parameters

$spec

array\Traversable

Exceptions

\Zend\Form\Exception\DomainException

Returns

Create an element based on the provided specification

createElement(array | \Traversable | \ArrayAccess $spec) : \Zend\Form\ElementInterface

Specification can contain any of the following: - type: the Element class to use; defaults to \Zend\Form\Element - name: what name to provide the element, if any - options: an array, Traversable, or ArrayAccess object of element options - attributes: an array, Traversable, or ArrayAccess object of element attributes to assign

Parameters

$spec

array\Traversable\ArrayAccess

Exceptions

\Zend\Form\Exception\InvalidArgumentException for an invalid $spec
\Zend\Form\Exception\DomainException for an invalid element type

Returns

Create a fieldset based on the provided specification

createFieldset(array | \Traversable | \ArrayAccess $spec) : \Zend\Form\FieldsetInterface

Specification can contain any of the following: - type: the Fieldset class to use; defaults to \Zend\Form\Fieldset - name: what name to provide the fieldset, if any - options: an array, Traversable, or ArrayAccess object of element options - attributes: an array, Traversable, or ArrayAccess object of element attributes to assign - elements: an array or Traversable object where each entry is an array or ArrayAccess object containing the keys: - flags: (optional) array of flags to pass to FieldsetInterface::add() - spec: the actual element specification, per createElement()

Parameters

$spec

array\Traversable\ArrayAccess

Exceptions

\Zend\Form\Exception\InvalidArgumentException for an invalid $spec
\Zend\Form\Exception\DomainException for an invalid fieldset type

Returns

Create a form based on the provided specification

createForm(array | \Traversable | \ArrayAccess $spec) : \Zend\Form\FormInterface

Specification follows that of createFieldset(), and adds the following keys:

  • input_filter: input filter instance, named input filter class, or array specification for the input filter factory
  • hydrator: hydrator instance or named hydrator class

Parameters

$spec

array\Traversable\ArrayAccess

Exceptions

\Zend\Form\Exception\InvalidArgumentException for an invalid $spec
\Zend\Form\Exception\DomainException for an invalid form type

Returns

Get current input filter factory

getInputFilterFactory() : \Zend\InputFilter\Factory

If none provided, uses an unconfigured instance.

Returns

Takes a list of fieldset specifications, creates the fieldsets, and injects them into the master fieldset

prepareAndInjectFieldsets(array | \Traversable | \ArrayAccess $fieldsets, \Zend\Form\FieldsetInterface $masterFieldset, string $method) : void

Parameters

$fieldsets

array\Traversable\ArrayAccess

$method

string

Method invoking this one (for exception messages)

Set input filter factory to use when creating forms

setInputFilterFactory(\Zend\InputFilter\Factory $inputFilterFactory) : \Zend\Form\Factory

Parameters

$inputFilterFactory

\Zend\InputFilter\Factory

Returns

Checks if the object has this class as one of its parents

isSubclassOf(string $className, string $type) : bool

see \Zend\Form\https://bugs.php.net/bug.php?id=53727
see \Zend\Form\https://github.com/zendframework/zf2/pull/1807

Parameters

$className

string

$type

string

Returns

bool

Takes a list of element specifications, creates the elements, and injects them into the provided fieldset

prepareAndInjectElements(array | \Traversable | \ArrayAccess $elements, \Zend\Form\FieldsetInterface $fieldset, string $method) : void

Parameters

$elements

array\Traversable\ArrayAccess

$method

string

Method invoking this one (for exception messages)

Prepare and inject a named hydrator

prepareAndInjectHydrator(string $hydratorOrName, \Zend\Form\FieldsetInterface $fieldset, string $method) : void

Takes a string indicating a hydrator class name (or a concrete instance), instantiates the class by that name, and injects the hydrator instance into the form.

Parameters

$hydratorOrName

string

$method

string

Exceptions

\Zend\Form\Exception\DomainException If $hydratorOrName is not a string, does not resolve to a known class, or the class does not implement Hydrator\HydratorInterface

Prepare an input filter instance and inject in the provided form

prepareAndInjectInputFilter(string | array | \Traversable $spec, \Zend\Form\FormInterface $form, string $method) : void

If the input filter specified is a string, assumes it is a class name, and attempts to instantiate it. If the class does not exist, or does not extend InputFilterInterface, an exception is raised.

Otherwise, $spec is passed on to the attached InputFilter Factory instance in order to create the input filter.

Parameters

$spec

stringarray\Traversable

$method

string

Exceptions

\Zend\Form\Exception\DomainException for unknown InputFilter class or invalid InputFilter instance

Prepare and inject an object

prepareAndInjectObject(string $objectName, \Zend\Form\FieldsetInterface $fieldset, string $method) : void

Takes a string indicating a class name, instantiates the class by that name, and injects the class instance as the bound object.

Parameters

$objectName

string

$method

string

Exceptions

\Zend\Form\Exception\DomainException

Prepare a validation group and inject in the provided form

prepareAndInjectValidationGroup(string | array | \Traversable $spec, \Zend\Form\FormInterface $form, string $method) : void

Takes an array of elements names

Parameters

$spec

stringarray\Traversable

$method

string

Exceptions

\Zend\Form\Exception\DomainException if validation group given is not an array

Validate a provided specification

validateSpecification(array | \Traversable | \ArrayAccess $spec, string $method) : array | \ArrayAccess

Ensures we have an array, Traversable, or ArrayAccess object, and returns it.

Parameters

$spec

array\Traversable\ArrayAccess

$method

string

Method invoking the validator

Exceptions

\Zend\Form\Exception\InvalidArgumentException for invalid $spec

Returns

array\ArrayAccess

 Properties

 

$inputFilterFactory

$inputFilterFactory : \Zend\InputFilter\Factory