Datalistentry: invert control

This commit is contained in:
Thomas Gelf 2015-07-31 17:25:49 +02:00
parent d3bad2f4bb
commit c7718ebd8f
2 changed files with 14 additions and 3 deletions

View File

@ -40,6 +40,7 @@ class Director_DatalistentryController extends ActionController
}
$form = $this->view->form = $this->loadForm('directorDatalistentry')
->setListId($listId)
->setSuccessUrl('director/datalistentry' . '?list_id=' . $listId)
->setDb($this->db());

View File

@ -6,6 +6,8 @@ use Icinga\Module\Director\Web\Form\DirectorObjectForm;
class DirectorDatalistEntryForm extends DirectorObjectForm
{
protected $listId;
public function setup()
{
$this->addElement('text', 'entry_name', array(
@ -18,9 +20,17 @@ class DirectorDatalistEntryForm extends DirectorObjectForm
'label' => 'Type',
'multiOptions' => array('string' => $this->translate('String'))
));
}
$this->addElement('hidden', 'list_id', array(
'value' => $this->getRequest()->getParam('list_id'),
));
public function onSuccess()
{
$this->object()->list_id = $this->listId;
parent::onSuccess();
}
public function setListId($id)
{
$this->listId = $id;
return $this;
}
}