diff options
Diffstat (limited to '')
-rw-r--r-- | application/forms/DirectorDatalistForm.php | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/application/forms/DirectorDatalistForm.php b/application/forms/DirectorDatalistForm.php new file mode 100644 index 0000000..91c0ea7 --- /dev/null +++ b/application/forms/DirectorDatalistForm.php @@ -0,0 +1,45 @@ +<?php + +namespace Icinga\Module\Director\Forms; + +use Icinga\Module\Director\Web\Form\DirectorObjectForm; +use Icinga\Authentication\Auth; + +class DirectorDatalistForm extends DirectorObjectForm +{ + public function setup() + { + $this->addElement('text', 'list_name', array( + 'label' => $this->translate('List name'), + 'description' => $this->translate( + 'Data lists are mainly used as data providers for custom variables' + . ' presented as dropdown boxes boxes. You can manually manage' + . ' their entries here in place, but you could also create dedicated' + . ' sync rules after creating a new empty list. This would allow you' + . ' to keep your available choices in sync with external data providers' + ), + 'required' => true, + )); + $this->addSimpleDisplayGroup(array('list_name'), 'list', array( + 'legend' => $this->translate('Data list') + )); + + $this->setButtons(); + } + + public function onSuccess() + { + $this->object()->set('owner', self::username()); + parent::onSuccess(); + } + + protected static function username() + { + $auth = Auth::getInstance(); + if ($auth->isAuthenticated()) { + return $auth->getUser()->getUsername(); + } else { + return '<unknown>'; + } + } +} |