package Default

 Methods

__construct()

__construct(\Zend\Form\FormElementManager $formElementManager = null

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

$element

\Zend\Form\ElementInterface

$spec

array\Traversable\ArrayAccess

Exceptions

\Zend\Form\Exception\DomainException

Returns

\Zend\Form\ElementInterface

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

$fieldset

\Zend\Form\FieldsetInterface

$spec

array\Traversable\ArrayAccess

Exceptions

\Zend\Form\Exception\DomainException

Returns

\Zend\Form\FieldsetInterface

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

$form

\Zend\Form\FormInterface

$spec

array\Traversable\ArrayAccess

Returns

\Zend\Form\FormInterface

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

\Zend\Form\ElementInterface

Create an element

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

Parameters

$spec

array

Returns

\Zend\Form\ElementInterface

Create a fieldset

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

Parameters

$spec

array

Returns

\Zend\Form\ElementInterface

Create a form

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

Parameters

$spec

array

Returns

\Zend\Form\ElementInterface

Get form element manager

getFormElementManager() : \Zend\Form\FormElementManager

Returns

\Zend\Form\FormElementManager

Get current input filter factory

getInputFilterFactory() : \Zend\InputFilter\Factory

If none provided, uses an unconfigured instance.

Returns

\Zend\InputFilter\Factory

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

$masterFieldset

\Zend\Form\FieldsetInterface

$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

\Zend\Form\Factory

Set input filter factory to use when creating forms

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

Parameters

$inputFilterFactory

\Zend\InputFilter\Factory

Returns

\Zend\Form\Factory

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

getFactoryFromName(string $factoryName) : mixed

Parameters

$factoryName

string

Exceptions

\Zend\Form\Exception\DomainException

Returns

mixed

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

$fieldset

\Zend\Form\FieldsetInterface

$method

string

Method invoking this one (for exception messages)

Prepare and inject a named factory

prepareAndInjectFactory(string|array|\Zend\Form\Factory $factoryOrName, \Zend\Form\FieldsetInterface $fieldset, string $method) : void

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

Parameters

$factoryOrName

stringarray\Zend\Form\Factory

$fieldset

\Zend\Form\FieldsetInterface

$method

string

Exceptions

\Zend\Form\Exception\DomainException If $factoryOrName is not a string, does not resolve to a known class, or the class does not extend Form\Factory

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

$fieldset

\Zend\Form\FieldsetInterface

$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

$form

\Zend\Form\FormInterface

$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

$fieldset

\Zend\Form\FieldsetInterface

$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

$form

\Zend\Form\FormInterface

$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

Default

 

$inputFilterFactory

$inputFilterFactory : \Zend\InputFilter\Factory

Default