getSelect() 공개 메소드

Return array for input select
public getSelect ( ) : array
리턴 array
예제 #1
0
 /**
  * Create document
  *
  * @return \Zend\View\Model\ViewModel|array
  */
 public function createAction()
 {
     $documentForm = new Form\DocumentInformation();
     $parentId = $this->getRouteMatch()->getParam('id');
     if (!empty($parentId)) {
         $routeName = 'content/document/create-w-parent';
     } else {
         $routeName = 'content/document/create';
     }
     $documentForm->setAttribute('action', $this->url()->fromRoute($routeName, array('id' => $parentId)));
     $documentTypeCollection = new DocumentType\Collection();
     $documentTypeElement = $documentForm->get('document_type');
     if (empty($parentId)) {
         $documentTypeElement->setValueOptions(array('' => 'Select document type') + $documentTypeCollection->getSelect());
     } else {
         $documentForm->get('parent')->setValue($parentId);
         $documentTypeCollection->init(DocumentModel::fromId($parentId)->getDocumentTypeId());
         $documentTypeElement->setValueOptions(array('' => 'Select document type') + $documentTypeCollection->getSelect());
     }
     if ($this->getRequest()->isPost()) {
         $documentForm->getInputFilter()->add(array('required' => true, 'validators' => array(array('name' => 'not_empty'))), 'document_type');
         $documentForm->setData($this->getRequest()->getPost()->toArray());
         if (!$documentForm->isValid()) {
             $this->flashMessenger()->addErrorMessage('Invalid document data');
             $this->useFlashMessenger();
         } else {
             $documentName = $documentForm->getValue('document-name');
             $documentUrlKey = $documentForm->getValue('document-url_key');
             $documentTypeId = $documentForm->getValue('document_type');
             $parentId = $documentForm->getValue('parent');
             $document = new DocumentModel();
             $document->setName($documentName)->setDocumentTypeId($documentTypeId)->setParentId($parentId)->setUrlKey(!empty($documentUrlKey) ? $documentUrlKey : $this->checkUrlKey($documentName))->setUserId($this->getServiceLocator()->get('Auth')->getIdentity()->getId());
             $document->save();
             $this->flashMessenger()->addSuccessMessage('This document has been saved');
             $this->redirect()->toRoute('content/document/edit', array('id' => $document->getId()));
         }
     }
     return array('form' => $documentForm);
 }
예제 #2
0
 /**
  * Test
  *
  * @return void
  */
 public function testGetSelect()
 {
     $this->object->init();
     $this->assertInternalType('array', $this->object->getSelect());
 }
예제 #3
0
 /**
  * Initialize infos sub form
  *
  * @return \Zend\Form\FieldSet
  */
 protected function getInfos()
 {
     $fieldsets = $this->getFieldSets();
     if (!empty($fieldsets['infos'])) {
         return $fieldsets['infos'];
     }
     $fieldsets = new FieldSet('infos');
     $this->getInputFilter()->add(array('type' => 'Zend\\InputFilter\\InputFilter', 'name' => array('name' => 'name', 'required' => true, 'validators' => array(array('name' => 'not_empty'), array('name' => 'db\\no_record_exists', 'options' => array('table' => 'document_type', 'field' => 'name', 'adapter' => $this->getAdapter())))), 'description' => array('name' => 'description', 'required' => false, 'allow_empty' => true), 'icon_id' => array('name' => 'icon_id', 'required' => true, 'allow_empty' => false), 'dependency' => array('name' => 'dependency', 'required' => false, 'allow_empty' => true)), 'infos');
     $fieldsets->add(new Element\Text('name'));
     $fieldsets->add(new Element\Text('description'));
     $iconId = new Element\Select('icon_id');
     $collection = new Icon\Collection();
     $iconId->setValueOptions($collection->getIcons())->setAttribute('class', 'form-control');
     $fieldsets->add($iconId);
     $documentTypeCollection = new DocumentTypeCollection();
     $select = $documentTypeCollection->getSelect();
     if (!empty($select)) {
         $dependency = new Element\MultiCheckbox('infos[dependency]');
         $dependency->setAttribute('class', 'input-checkbox');
         $dependency->setValueOptions($documentTypeCollection->getSelect());
         $fieldsets->add($dependency);
     }
     $this->add($fieldsets);
     return $fieldsets;
 }