/**
  * @see Zend\Form\Element\Collection
  */
 public function prepareElement(FormInterface $form)
 {
     Form::workOnElement($form->getInputByElement($this), $this->getTargetElement());
     if (true === $this->shouldCreateChildrenOnPrepareElement) {
         if ($this->targetElement !== null && $this->count > 0 && $this->_collection) {
             while ($this->count > $this->lastChildIndex + 1 && $this->lastChildIndex + 2 <= count($this->_collection)) {
                 $this->addNewTargetElementInstance($this->_collection[++$this->lastChildIndex]);
             }
         }
     }
     // Create a template that will also be prepared
     if ($this->shouldCreateTemplate) {
         $templateElement = $this->getTemplateElement();
         $this->add($templateElement);
         parent::prepareElement($form);
         // The template element has been prepared, but we don't want it to be
         // rendered nor validated, so remove it from the list.
         if ($this->shouldCreateTemplate) {
             $this->remove($this->templatePlaceholder);
         }
     }
 }