Example #1
0
 public static function create(array $elementData, ElementInterface $element, AnnotatedForm $form, EntityToForm $e2f)
 {
     $type = isset($elementData['type']) ? $elementData['type'] : '';
     if (empty($type)) {
         // inferr type from ZF2 Form Element type
         $clsName = get_class($element);
         $parts = explode('\\', $clsName);
         $type = end($parts);
     }
     switch (strtolower(trim($type))) {
         case 'subform':
             $annotation = new Subform($elementData);
             // do not 'setZendFormElement' because this element is replaced by the subform
             $annotation->populateFromParent($form, $e2f);
             break;
         case 'select':
             $annotation = new Select($elementData);
             $annotation->setZendFormElement($element);
             break;
         case 'checkbox':
             $annotation = new Checkbox($elementData);
             $annotation->setZendFormElement($element);
             break;
         case 'multicheckbox':
             // MultiCheckbox isn't fully implemented at this time, this is just a stub
             $annotation = new MultiCheckbox($elementData);
             $annotation->setZendFormElement($element);
             break;
         case 'radio':
             $annotation = new Radio($elementData);
             $annotation->setZendFormElement($element);
             break;
         case 'wysiwyg':
             $annotation = new Wysiwyg($elementData);
             $annotation->setZendFormElement($element);
             break;
         default:
             $annotation = new Field($elementData);
             $annotation->setZendFormElement($element);
     }
     $annotation->setParentForm($form);
     return $annotation;
 }
Example #2
0
 public function setZendFormElement(ElementInterface $element)
 {
     $element->setAttribute('data-ui-select2', $this->selectOptions);
     return parent::setZendFormElement($element);
 }