icingaweb2-module-director/application/controllers/DatafieldController.php

54 lines
1.3 KiB
PHP
Raw Normal View History

<?php
2015-10-20 22:34:04 +02:00
namespace Icinga\Module\Director\Controllers;
use Icinga\Module\Director\Web\Controller\ActionController;
2015-10-20 22:34:04 +02:00
class DatafieldController extends ActionController
{
2015-07-03 14:20:47 +02:00
public function addAction()
{
$this->indexAction();
2015-07-03 14:20:47 +02:00
}
public function editAction()
{
$this->indexAction();
2015-07-03 14:20:47 +02:00
}
public function indexAction()
{
$edit = false;
2016-02-27 21:04:13 +01:00
if ($id = $this->params->get('id')) {
$edit = true;
}
if ($edit) {
$this->view->title = $this->translate('Edit field');
$this->getTabs()->add('editfield', array(
'url' => 'director/datafield/edit' . '?id=' . $id,
'label' => $this->view->title,
))->activate('editfield');
} else {
$this->view->title = $this->translate('Add field');
$this->getTabs()->add('addfield', array(
'url' => 'director/datafield/add',
'label' => $this->view->title,
))->activate('addfield');
}
$form = $this->view->form = $this->loadForm('directorDatafield')
2016-03-01 20:56:53 +01:00
->setSuccessUrl('director/data/fields')
->setDb($this->db());
if ($edit) {
$form->loadObject($id);
}
2015-07-03 14:20:47 +02:00
$form->handleRequest();
$this->render('object/form', null, true);
}
}