Inheritance: extends Gc\Db\AbstractTable
Ejemplo n.º 1
0
 /**
  * Add property sub form
  *
  * @param mixed $property \Gc\Property\Model|array
  *
  * @return DocumentType
  */
 public function addProperty($property)
 {
     if (!is_array($property) and !$property instanceof Property\Model) {
         return $this;
     }
     $fieldsets = $this->getProperties();
     $name = new Element\Text('name');
     $identifier = new Element('identifier');
     $tab = new Element\Select('tab');
     $tab->setAttribute('class', 'select-tab')->setValueOptions(array());
     $datatype = new Element\Select('datatype');
     $datatype->setAttribute('class', 'select-datatype')->setValueOptions($this->datatypeCollection->getSelect());
     $description = new Element\Text('description');
     $required = new Element\Checkbox('required');
     $required->setCheckedValue('1')->setAttribute('id', 'required')->setAttribute('class', 'input-checkbox');
     $propertyId = new Element\Hidden('property_id');
     if ($property instanceof Property\Model) {
         $name->setValue($property->getName());
         $identifier->setValue($property->getIdentifier());
         $tab->setValue($property->getTabId());
         $datatype->setValue($property->getDatatypeId());
         $description->setValue($property->getDescription());
         $required->setValue((string) $property->isRequired());
         $propertyId->setValue($property->getId());
         $propertyFieldsetName = $property->getId();
     } else {
         $name->setValue($property['name']);
         $identifier->setValue($property['identifier']);
         $tab->setValue($property['tab']);
         $datatype->setValue($property['datatype']);
         $description->setValue($property['description']);
         $required->setValue((string) (!empty($property['isRequired'])));
         $propertyId->setValue(str_replace('property', '', $property['id']));
         $propertyFieldsetName = $property['id'];
     }
     $propertyForm = new FieldSet($propertyFieldsetName);
     $propertyForm->add($propertyId);
     $propertyForm->add($name);
     $propertyForm->add($identifier);
     $propertyForm->add($tab);
     $propertyForm->add($datatype);
     $propertyForm->add($description);
     $propertyForm->add($required);
     $fieldsets->add($propertyForm);
     $this->getInputFilter()->get('properties')->add(array('type' => 'Zend\\InputFilter\\InputFilter', 'name' => array('name' => 'name', 'required' => true, 'validators' => array(array('name' => 'not_empty'))), 'identifier' => array('name' => 'identifier', 'required' => true, 'validators' => array(array('name' => 'not_empty'), array('name' => 'regex', 'options' => array('pattern' => parent::IDENTIFIER_PATTERN)))), 'tab' => array('name' => 'tab', 'required' => true, 'validators' => array(array('name' => 'not_empty'))), 'datatype' => array('name' => 'datatype', 'required' => true, 'validators' => array(array('name' => 'not_empty'))), 'description' => array('name' => 'description', 'required' => false, 'allow_empty' => true), 'required' => array('name' => 'required', 'required' => false, 'allow_empty' => true)), $propertyFieldsetName);
     return $this;
 }
Ejemplo n.º 2
0
 /**
  * Test
  *
  * @return void
  */
 public function testGetSelect()
 {
     $this->assertInternalType('array', $this->object->getSelect());
 }
Ejemplo n.º 3
0
 /**
  * List all datatypes
  *
  * @return \Zend\View\Model\ViewModel|array
  */
 public function indexAction()
 {
     $datatypes = new Datatype\Collection();
     return array('datatypes' => $datatypes->getDatatypes());
 }