mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-31 01:34:12 +02:00
IcingaHostForm: Use fields
This commit is contained in:
parent
e4bf3ee370
commit
d7f3c596d6
@ -2,6 +2,7 @@
|
||||
|
||||
namespace Icinga\Module\Director\Forms;
|
||||
|
||||
use Icinga\Module\Director\Objects\DirectorDatafield;
|
||||
use Icinga\Module\Director\Web\Form\DirectorObjectForm;
|
||||
|
||||
class IcingaHostForm extends DirectorObjectForm
|
||||
@ -100,4 +101,36 @@ class IcingaHostForm extends DirectorObjectForm
|
||||
'description' => $this->translate('Check this host in this specific Icinga cluster zone')
|
||||
));
|
||||
}
|
||||
|
||||
public function loadObject($id)
|
||||
{
|
||||
parent::loadObject($id);
|
||||
|
||||
$this->addFields();
|
||||
|
||||
$this->moveSubmitToBottom();
|
||||
}
|
||||
|
||||
public function addFields()
|
||||
{
|
||||
$fields = $this->getObject()->getFields($this);
|
||||
$vars = $this->getObject()->vars();
|
||||
|
||||
foreach ($fields as $field) {
|
||||
$datatype = new $field->datatype;
|
||||
$datafield = DirectorDatafield::load($field->datafield_id, $this->getDb());
|
||||
$datatype->setSettings($datafield->getSettings());
|
||||
$el = $datatype->getFormElement('var_' . $datafield->varname, $this);
|
||||
$el->setLabel($field->caption);
|
||||
$el->setDescription($field->description);
|
||||
$el->setValue($vars->{$datafield->varname}->getValue());
|
||||
|
||||
if ($field->is_required === 'y')
|
||||
{
|
||||
$el->setRequired(true);
|
||||
}
|
||||
|
||||
$this->addElement($el);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user