예제 #1
0
 /**
  * @see Form::createElemeents()
  */
 public function createElements(array $formData)
 {
     $resourceType = isset($formData['type']) ? $formData['type'] : 'db';
     $resourceTypes = array('file' => $this->translate('File'), 'livestatus' => 'Livestatus', 'ssh' => $this->translate('SSH Identity'));
     if ($resourceType === 'ldap' || Platform::hasLdapSupport()) {
         $resourceTypes['ldap'] = 'LDAP';
     }
     if ($resourceType === 'db' || Platform::hasDatabaseSupport()) {
         $resourceTypes['db'] = $this->translate('SQL Database');
     }
     $this->addElement('select', 'type', array('required' => true, 'autosubmit' => true, 'label' => $this->translate('Resource Type'), 'description' => $this->translate('The type of resource'), 'multiOptions' => $resourceTypes, 'value' => $resourceType));
     if (isset($formData['force_creation']) && $formData['force_creation']) {
         // In case another error occured and the checkbox was displayed before
         $this->addElement($this->getForceCreationCheckbox());
     }
     $this->addElements($this->getResourceForm($resourceType)->createElements($formData)->getElements());
 }