public function getFormElement($name, QuickForm $form) { try { $data = $this->fetchData(); $error = false; } catch (Exception $e) { $data = array(); $error = sprintf($form->translate('Unable to fetch data: %s'), $e->getMessage()); } $element = $form->createElement('select', $name, array('multiOptions' => $form->optionalEnum($data))); if ($error) { $element->addError($error); } return $element; }
protected static function addResourceFormElement(QuickForm $form, $name, $type) { $list = self::enumResources($type); $form->addElement('select', $name, array('label' => 'Resource name', 'multiOptions' => $form->optionalEnum($list), 'required' => true)); if (true && empty($list)) { if (self::hasPermission('config/application/resources')) { $hint = $form->translate('Please click %s to create new resources'); $link = sprintf('<a href="' . Url::fromPath('config/resource') . '" data-base-target="_main">%s</a>', $form->translate('here')); $form->addHtmlHint(sprintf($hint, $link)); $msg = $form->translate('No db resource available'); } else { $msg = $form->translate('Please ask an administrator to grant you access to resources'); } $form->getElement($name)->addError($msg); } }
public function getFormElement($name, QuickForm $form) { $element = $form->createElement('text', $name); return $element; }
protected static function enumFiles($basedir, QuickForm $form) { return array_merge(array('*' => sprintf('* (%s)', $form->translate('all files'))), static::listFiles($basedir)); }
public static function addSettingsFormFields(QuickForm $form) { $pdb = new PuppetDb(); $form->addElement('select', 'api_version', array('label' => 'API version', 'required' => true, 'multiOptions' => array('v4' => 'v4: PuppetDB 2.3, 3.0, 3.1, 3.2, 4.0 (PE 3.8, 2015.2, 2015.3)', 'v3' => 'v3: PuppetDB 1.5, 1.6 (PE 3.1, 3.2, 3.3)', 'v2' => 'v2: PuppetDB 1.1, 1.2, 1.3, 1.4', 'v1' => 'v1: PuppetDB 1.0'))); $form->addElement('select', 'server', array('label' => 'PuppetDB Server', 'required' => true, 'multiOptions' => $form->optionalEnum($pdb->listServers()), 'class' => 'autosubmit')); if (!($server = $form->getSentOrObjectSetting('server'))) { return $form; } $form->addElement('select', 'client_cert', array('label' => 'Client Certificate', 'required' => true, 'class' => 'autosubmit', 'multiOptions' => $form->optionalEnum($pdb->listClientCerts($server)))); if (!($cert = $form->getSentOrObjectSetting('client_cert'))) { return; } $form->addElement('select', 'query_type', array('label' => 'Query type', 'required' => true, 'class' => 'autosubmit', 'multiOptions' => $form->optionalEnum(array('resource' => $form->translate('Resources'), 'node' => $form->translate('Nodes'))))); if (!($queryType = $form->getSentOrObjectSetting('query_type'))) { return; } try { $db = new PuppetDbApi($form->getSentOrObjectSetting('api_version'), $cert, $server); $resourceTypes = $db->enumResourceTypes(); } catch (Exception $e) { $form->addError(sprintf($form->translate('Failed to load resource types: %s'), $e->getMessage())); } if (empty($resourceTypes)) { $form->addElement('text', 'resource_type', array('label' => 'Resource type', 'required' => true)); } else { $form->addElement('select', 'resource_type', array('label' => 'Resource type', 'required' => true, 'class' => 'autosubmit', 'multiOptions' => $form->optionalEnum($resourceTypes))); } }
public static function addSettingsFormFields(QuickForm $form) { $form->addElement('select', 'object_type', array('label' => 'Object type', 'required' => true, 'multiOptions' => $form->optionalEnum(array('CheckCommand' => 'Commands', 'Endpoint' => 'Endpoints', 'Host' => 'Host', 'Zone' => 'Zones')))); }
public static function addSettingsFormFields(QuickForm $form) { $db = $form->getDb(); $form->addElement('select', 'datalist_id', array('label' => 'List name', 'required' => true, 'multiOptions' => array(null => '- please choose -') + $db->enumDatalist())); return $form; }
public function onSuccess() { $this->importZones()->importEndpoints()->importCommands(); $this->apiUser()->store(); parent::onSuccess(); }