icingaweb2-module-director/application/forms/SyncPropertyForm.php

74 lines
2.3 KiB
PHP
Raw Normal View History

<?php
namespace Icinga\Module\Director\Forms;
use Icinga\Module\Director\Web\Form\DirectorObjectForm;
use Icinga\Web\Hook;
class SyncPropertyForm extends DirectorObjectForm
{
public function setup()
{
$this->addElement('select', 'rule_id', array(
2015-07-28 11:43:40 +02:00
'label' => $this->translate('Rule Name'),
'required' => true,
));
$this->addElement('select', 'source_id', array(
2015-07-28 11:43:40 +02:00
'label' => $this->translate('Source Name'),
'required' => true,
));
$this->addElement('text', 'source_expression', array(
2015-07-28 11:43:40 +02:00
'label' => $this->translate('Source Expression'),
'required' => true,
));
$this->addElement('text', 'destination_field', array(
2015-07-28 11:43:40 +02:00
'label' => $this->translate('Destination Field'),
'required' => true,
));
$this->addElement('text', 'priority', array(
2015-07-28 11:43:40 +02:00
'label' => $this->translate('Priority'),
'description' => $this->translate('Priority for the specified source expression'),
'required' => true,
));
$this->addElement('text', 'filter_expression', array(
2015-07-28 11:43:40 +02:00
'label' => $this->translate('Filter Expression'),
'description' => $this->translate('This allows to filter for specific parts within the given source expression'),
'required' => false,
));
$this->addElement('select', 'merge_policy', array(
2015-07-28 11:43:40 +02:00
'label' => $this->translate('Merge Policy'),
'description' => $this->translate('Whether you want to merge or override the destination field'),
'required' => true,
'multiOptions' => array(
2015-07-28 11:43:40 +02:00
'null' => '- please choose -',
'merge' => 'merge',
'override' => 'override'
)
));
}
public function loadObject($id)
{
parent::loadObject($id);
return $this;
}
public function setDb($db)
{
parent::setDb($db);
$this->prepareElements();
$this->getElement('rule_id')->setMultiOptions($this->optionalEnum($db->enumSyncRule()));
$this->getElement('source_id')->setMultiOptions($this->optionalEnum($db->enumImportSource()));
return $this;
}
}