Methods

__construct()

__construct(\Zend\Form\FormElementManager $formElementManager) 

Parameters

$formElementManager

\Zend\Form\FormElementManager

Configure an element based on the provided specification

configureElement(\Zend\Form\ElementInterface $element, 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\DomainException

Returns

Configure a fieldset based on the provided specification

configureFieldset(\Zend\Form\FieldsetInterface $fieldset, 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 configureElement()

Parameters

$spec

array\Traversable\ArrayAccess

Exceptions

\Zend\Form\Exception\DomainException

Returns

Configure a form based on the provided specification

configureForm(\Zend\Form\FormInterface $form, array | \Traversable | \ArrayAccess $spec) : \Zend\Form\FormInterface

Specification follows that of configureFieldset(), 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

Returns

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

createElement(array $spec) : \Zend\Form\ElementInterface

Parameters

$spec

array

Returns

Create a fieldset

createFieldset(array $spec) : \Zend\Form\ElementInterface

Parameters

$spec

array

Returns

Create a form

createForm(array $spec) : \Zend\Form\ElementInterface

Parameters

$spec

array

Returns

Get form element manager

getFormElementManager() : \Zend\Form\FormElementManager

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 the form element manager

setFormElementManager(\Zend\Form\FormElementManager $formElementManager) : \Zend\Form\Factory

Parameters

$formElementManager

\Zend\Form\FormElementManager

Returns

Set input filter factory to use when creating forms

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

Parameters

$inputFilterFactory

\Zend\InputFilter\Factory

Returns

Try to pull hydrator from service manager, or instantiates it from its name

getHydratorFromName(string $hydratorName) : mixed

Parameters

$hydratorName

string

Exceptions

\Zend\Form\Exception\DomainException

Returns

mixed

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 | array | \Zend\Stdlib\Hydrator\HydratorInterface $hydratorOrName, \Zend\Form\FieldsetInterface $fieldset, string $method) : void

Takes a string indicating a hydrator class name (or a concrete instance), try first to instantiates the class by pulling it from service manager, and injects the hydrator instance into the form.

Parameters

$hydratorOrName

stringarray\Zend\Stdlib\Hydrator\HydratorInterface

$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

 

$formElementManager

$formElementManager : \Zend\Form\FormElementManager

 

$inputFilterFactory

$inputFilterFactory : \Zend\InputFilter\Factory