1<?php 2 3namespace Icinga\Module\Director\Controllers; 4 5use Icinga\Module\Director\Forms\DirectorDatafieldForm; 6use Icinga\Module\Director\Web\Controller\ActionController; 7 8class DatafieldController extends ActionController 9{ 10 public function addAction() 11 { 12 $this->indexAction(); 13 } 14 15 public function editAction() 16 { 17 $this->indexAction(); 18 } 19 20 public function indexAction() 21 { 22 $edit = false; 23 24 if ($id = $this->params->get('id')) { 25 $edit = true; 26 } 27 28 $form = DirectorDatafieldForm::load() 29 ->setSuccessUrl('director/data/fields') 30 ->setDb($this->db()); 31 32 if ($edit) { 33 $form->loadObject($id); 34 $this->addTitle( 35 $this->translate('Modify %s'), 36 $form->getObject()->varname 37 ); 38 $this->addSingleTab($this->translate('Edit a Field')); 39 } else { 40 $this->addTitle($this->translate('Add a new Data Field')); 41 $this->addSingleTab($this->translate('New Field')); 42 } 43 44 $form->handleRequest(); 45 $this->content()->add($form); 46 } 47} 48