public function createElements(array $formData) { $instanceConfigForm = new InstanceConfigForm(); $instanceConfigForm->createElements($formData); $this->addElements($instanceConfigForm->getElements()); $this->getElement('name')->setValue('icinga'); }
public function createElements(array $formData) { if (isset($formData['host'])) { $formData['type'] = 'remote'; // This is necessary as the type element gets ignored by Form::getValues() } $instanceConfigForm = new InstanceConfigForm(); $instanceConfigForm->createElements($formData); $this->addElements($instanceConfigForm->getElements()); $this->getElement('name')->setValue('icinga'); }
/** * Display a form to create a new instance */ public function createinstanceAction() { $form = new InstanceConfigForm(); $form->setTitle($this->translate('Add New Instance')); $form->setIniConfig($this->Config('instances')); $form->setRedirectUrl('monitoring/config'); $form->handleRequest(); $this->view->form = $form; }
/** * Create a new monitoring instance */ public function createinstanceAction() { $form = new InstanceConfigForm(); $form->setRedirectUrl('monitoring/config'); $form->setTitle($this->translate('Create New Monitoring Instance')); $form->setIniConfig($this->Config('instances')); $form->setOnSuccess(function (InstanceConfigForm $form) { try { $form->add(array_filter($form->getValues())); } catch (Exception $e) { $form->error($e->getMessage()); return false; } if ($form->save()) { Notification::success(t('Monitoring instance successfully created')); return true; } return false; }); $form->handleRequest(); $this->view->form = $form; $this->render('form'); }