Zend\Form\Element\Collection
Synopsis
class Collection
extends Fieldset
{
- // constants
- const DEFAULT_TEMPLATE_PLACEHOLDER = '__index__';
- // members
- protected ElementInterface $targetElement;
- protected integer $count;
- protected bool $allowAdd;
- protected bool $allowRemove;
- protected bool $shouldCreateTemplate;
- protected string $templatePlaceholder;
- protected bool $createNewObjects;
- protected ElementInterface|FieldsetInterface $templateElement;
- protected integer $lastChildIndex;
- protected bool $shouldCreateChildrenOnPrepareElement;
- // Inherited members from Fieldset
- protected Factory $factory;
- protected array $byName;
- protected array $elements;
- protected array $fieldsets;
- protected array $messages;
- protected PriorityQueue $iterator;
- protected HydratorInterface $hydrator;
- protected null|object $object;
- protected bool $useAsBaseFieldset;
- protected string $allowedObjectBindingClass;
- // Inherited members from Element
- protected array $attributes;
- protected null|string $label;
- protected array $labelAttributes;
- protected array $labelOptions;
- protected array $messages;
- protected array $options;
- protected mixed $value;
- // methods
- public Collection setOptions()
- public bool allowObjectBinding()
- public Fieldset|FieldsetInterface setObject()
- public void populateValues()
- public bool allowValueBinding()
- public array|mixed|void bindValues()
- public Collection setCount()
- public int getCount()
- public Collection setTargetElement()
- public ElementInterface|null getTargetElement()
- public Collection setAllowAdd()
- public bool allowAdd()
- public Collection setAllowRemove()
- public bool allowRemove()
- public Collection setShouldCreateTemplate()
- public bool shouldCreateTemplate()
- public Collection setTemplatePlaceholder()
- public string getTemplatePlaceholder()
- public Collection setCreateNewObjects()
- public bool createNewObjects()
- public null|ElementInterface|FieldsetInterface getTemplateElement()
- public mixed|void prepareElement()
- public array extract()
- protected ElementInterface createNewTargetElementInstance()
- protected ElementInterface addNewTargetElementInstance()
- protected null|ElementInterface|FieldsetInterface createTemplateElement()
- protected void replaceTemplateObjects()
- // Inherited methods from Fieldset
- public void __construct()
- public Element|ElementInterface setOptions()
- public Form setFormFactory()
- public Factory getFormFactory()
- public Fieldset|FieldsetInterface add()
- public bool has()
- public ElementInterface get()
- public FieldsetInterface remove()
- public FieldsetInterface setPriority()
- public array|Traversable getElements()
- public array|Traversable getFieldsets()
- public Element|ElementInterface|FieldsetInterface setMessages()
- public array|Traversable getMessages()
- public mixed|void prepareElement()
- public void populateValues()
- public int count()
- public PriorityQueue getIterator()
- public Fieldset|FieldsetInterface setObject()
- public mixed getObject()
- public void setAllowedObjectBindingClass()
- public string allowedObjectBindingClass()
- public bool allowObjectBinding()
- public FieldsetInterface setHydrator()
- public HydratorInterface getHydrator()
- public bool allowValueBinding()
- public mixed|void bindValues()
- public Fieldset setUseAsBaseFieldset()
- public bool useAsBaseFieldset()
- protected array extract()
- public void __clone()
- // Inherited methods from Element
- public void __construct()
- public void init()
- public Element|ElementInterface setName()
- public string|int getName()
- public Element|ElementInterface setOptions()
- public array getOptions()
- public NULL|mixed getOption()
- public self setOption()
- public Element|ElementInterface setAttribute()
- public mixed|null getAttribute()
- public ElementInterface removeAttribute()
- public bool hasAttribute()
- public Element|ElementInterface setAttributes()
- public array|Traversable getAttributes()
- public ElementInterface removeAttributes()
- public Element|ElementInterface clearAttributes()
- public Element setValue()
- public mixed getValue()
- public Element|ElementInterface setLabel()
- public null|string getLabel()
- public Element|ElementInterface setLabelAttributes()
- public array getLabelAttributes()
- public Element|ElementInterface setLabelOptions()
- public array getLabelOptions()
- public Element|ElementInterface clearLabelOptions()
- public ElementInterface removeLabelOptions()
- public Element|ElementInterface setLabelOption()
- public mixed|null getLabelOption()
- public ElementInterface removeLabelOption()
- public bool hasLabelOption()
- public Element|ElementInterface setMessages()
- public array|Traversable getMessages()
Hierarchy
Extends
Tasks
Line | Task |
---|---|
152+ | Should we detect if the element/fieldset name conflicts? |
Constants
Name | Value |
---|---|
DEFAULT_TEMPLATE_PLACEHOLDER | '__index__' |
Members
protected
- $allowAdd
—
Zend\Form\Element\bool
Are new elements allowed to be added dynamically ? - $allowRemove
—
Zend\Form\Element\bool
Are existing elements allowed to be removed dynamically ? - $allowedObjectBindingClass
—
string
The class or interface of objects that can be bound to this fieldset. - $attributes — array
- $byName — array
- $count
—
int
Initial count of target element - $createNewObjects
—
Zend\Form\Element\bool
Whether or not to create new objects during modify - $elements — array
- $factory — Zend\Form\Factory
- $fieldsets — array
- $hydrator
—
Zend\Form\Hydrator\HydratorInterface
Hydrator to use with bound object - $iterator — Zend\Stdlib\PriorityQueue
- $label — Zend\Form\null|string
- $labelAttributes — array
- $labelOptions
—
array
Label specific options - $lastChildIndex
—
int
The index of the last child element or fieldset - $messages — array
- $messages — array
- $object
—
Zend\Form\null|object
The object bound to this fieldset, if any - $options — array
- $shouldCreateChildrenOnPrepareElement
—
Zend\Form\Element\bool
Should child elements must be created on self::prepareElement()? - $shouldCreateTemplate
—
Zend\Form\Element\bool
Is the template generated ? - $targetElement
—
Zend\Form\ElementInterface
Element used in the collection - $templateElement
—
Zend\Form\Element\ElementInterface|FieldsetInterface
Element used as a template - $templatePlaceholder
—
string
Placeholder used in template content for making your life easier with JavaScript - $useAsBaseFieldset
—
Zend\Form\bool
Should this fieldset be used as a base fieldset in the parent form ? - $value — mixed
Methods
protected
- addNewTargetElementInstance() — Add a new instance of the target element
- createNewTargetElementInstance() — Create a new instance of the target element
- createTemplateElement() — Create a dummy template element
- replaceTemplateObjects() — Replaces the default template object of a sub element with the corresponding real entity so that all properties are preserved.
public
- allowAdd() — Get allow add
- allowObjectBinding() — Checks if the object can be set in this fieldset
- allowRemove()
- allowValueBinding() — Checks if this fieldset can bind data
- bindValues() — Bind values to the object
- createNewObjects()
- extract()
- getCount() — Get the initial count of target element
- getTargetElement() — Get target element
- getTemplateElement() — Get a template element used for rendering purposes only
- getTemplatePlaceholder() — Get the template placeholder
- populateValues() — Populate values
- prepareElement() — Prepare the collection by adding a dummy template element if the user want one
- setAllowAdd() — Get allow add
- setAllowRemove()
- setCount() — Set the initial count of target element
- setCreateNewObjects()
- setObject() — Set the object used by the hydrator In this case the "object" is a collection of objects
- setOptions() — Accepted options for Collection: - target_element: an array or element used in the collection - count: number of times the element is added initially - allow_add: if set to true, elements can be added to the form dynamically (using JavaScript) - allow_remove: if set to true, elements can be removed to the form - should_create_template: if set to true, a template is generated (inside a <span>) - template_placeholder: placeholder used in the data template
- setShouldCreateTemplate() — If set to true, a template prototype is automatically added to the form to ease the creation of dynamic elements through JavaScript
- setTargetElement() — Set the target element
- setTemplatePlaceholder() — Set the placeholder used in the template generated to help create new elements in JavaScript
- shouldCreateTemplate() — Get if the collection should create a template
Inherited from Zend\Form\Fieldset
protected
- extract() — Extract values from the bound object
public
- __clone() — Make a deep clone of a fieldset
- add() — Add an element or fieldset
- allowObjectBinding() — Checks if the object can be set in this fieldset
- allowValueBinding() — Checks if this fieldset can bind data
- allowedObjectBindingClass() — Get The class or interface of objects that can be bound to this fieldset.
- bindValues() — Bind values to the bound object
- count() — Countable: return count of attached elements/fieldsets
- get() — Retrieve a named element or fieldset
- getElements() — Retrieve all attached elements
- getFieldsets() — Retrieve all attached fieldsets
- getFormFactory() — Retrieve composed form factory
- getHydrator() — Get the hydrator used when binding an object to the fieldset
- getIterator() — IteratorAggregate: return internal iterator
- getMessages() — Get validation error messages, if any
- getObject() — Get the object used by the hydrator
- has() — Does the fieldset have an element/fieldset by the given name?
- populateValues() — Recursively populate values of attached elements and fieldsets
- prepareElement() — 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
- remove() — Remove a named element or fieldset
- setAllowedObjectBindingClass() — Set the class or interface of objects that can be bound to this fieldset.
- setFormFactory() — Compose a form factory to use when calling add() with a non-element/fieldset
- setHydrator() — Set the hydrator to use when binding an object to the element
- setMessages() — Set a hash of element names/messages to use when validation fails
- setObject() — Set the object used by the hydrator
- setOptions() — Set options for a fieldset. Accepted options are: - use_as_base_fieldset: is this fieldset use as the base fieldset?
- setPriority() — Set/change the priority of an element or fieldset
- setUseAsBaseFieldset() — Set if this fieldset is used as a base fieldset
- useAsBaseFieldset() — Is this fieldset use as a base fieldset for a form ?
Inherited from Zend\Form\Element
public
- clearAttributes() — Clear all attributes
- clearLabelOptions() — Clear all label options
- getAttribute() — Retrieve a single element attribute
- getAttributes() — Retrieve all attributes at once
- getLabel() — Retrieve the label used for this element
- getLabelAttributes() — Get the attributes to use with the label
- getLabelOption() — Retrieve a single label option
- getLabelOptions() — Get label specific options
- getMessages() — Get validation error messages, if any.
- getName() — Get value for name
- getOption() — Return the specified option
- getOptions() — Get defined options
- getValue() — Retrieve the element value
- hasAttribute() — Does the element has a specific attribute ?
- hasLabelOption() — Does the element has a specific label option ?
- init() — This function is automatically called when creating element with factory. It allows to perform various operations (add elements...)
- removeAttribute() — Remove a single attribute
- removeAttributes() — Remove many attributes at once
- removeLabelOption() — Remove a single label option
- removeLabelOptions() — Remove many attributes at once
- setAttribute() — Set a single element attribute
- setAttributes() — Set many attributes at once
- setLabel() — Set the label used for this element
- setLabelAttributes() — Set the attributes to use with the label
- setLabelOption() — Set a single label optionn
- setLabelOptions() — Set many label options at once
- setMessages() — Set a list of messages to report when validation fails
- setName() — Set value for name
- setOption() — Set a single option for an element
- setOptions() — Set options for an element. Accepted options are: - label: label to associate with the element - label_attributes: attributes to use when the label is rendered - label_options: label specific options
- setValue() — Set the element value