<?php
 namespace Modules\Utils\Calendar\Listing; class View_Utils_FormAdmin extends \App\Mvc\View_Utils_FormAbstract { public function getForm() { $form = \Engine\Form\General::create(); $form->setStyle('width', '400'); $fieldset1 = \Engine\Form\Container\Fieldset::create($this->lang['fieldSet']['event']); $form->addContainer($fieldset1); $fld = new \Engine\Form\Input\Text($this->lang['formFields']['eventTitle'], 'title', $this->values['title']); $fld->setMandatory(); $fieldset1->addElement($fld); $fld = new \Engine\Form\Input\Textarea($this->lang['formFields']['eventDescription'], 'description', $this->values['description']); $fieldset1->addElement($fld); $fld = new \Engine\Form\Input\Text($this->lang['formFields']['eventLocation'], 'location', $this->values['location']); $fieldset1->addElement($fld); $fieldset2 = \Engine\Form\Container\Fieldset::create($this->lang['fieldSet']['dateAndTime']); $form->addContainer($fieldset2); $fldStartDateTime = new \Engine\Form\Input\Datetime($this->lang['formFields']['startDate'], 'startDateTime', $this->values['startDateTime']); $fldStartDateTime->setMandatory(); $fldEndDateTime = new \Engine\Form\Input\Datetime($this->lang['formFields']['endDate'], 'endDateTime', $this->values['endDateTime']); $fldEndDateTime->setMandatory(); $fldStartDate = new \Engine\Form\Input\Date($this->lang['formFields']['startDate'], 'startDate', $this->values['startDate']); $fldStartDate->setMandatory(); $fldEndDate = new \Engine\Form\Input\Date($this->lang['formFields']['endDate'], 'endDate', $this->values['endDate']); $fldEndDate->setMandatory(); $fld = new \Engine\Form\Input\Checkbox($this->lang['formFields']['allDay'], 'allDay', $this->values['allDay']); $fld->setControlledElements([ '0'=>[$fldStartDateTime, $fldEndDateTime], '1'=>[$fldStartDate, $fldEndDate], ]); $fieldset2->addElement($fld); $fieldset2->addElement($fldStartDateTime); $fieldset2->addElement($fldEndDateTime); $fieldset2->addElement($fldStartDate); $fieldset2->addElement($fldEndDate); $fieldset3 = \Engine\Form\Container\Fieldset::create($this->lang['fieldSet']['alert']); $form->addContainer($fieldset3); $fldEmail = new \Engine\Form\Input\Checkbox($this->lang['formFields']['sendEmail'], 'mailStatus', $this->values['mailStatus']); if ($this->controller->getAction()=='update' and $this->values['mailStatus']==2) { $fldEmail->setDisabled(); $fldEmail->setValue(true); } $fldEmail->setTooltip($this->lang['formFields']['sendMailTooltip']); if ($this->controller->getAction()=='insert') { $fld = new \Engine\Form\Input\Select($this->lang['formFields']['alert'], 'alertPeriod', $this->values['alertPeriod']); $possibleValuesAlert = ['' => $this->lang['reminder']['noReminder']]; foreach ($this->cfg['alertPeriodsList'] as $alertTime) { $possibleValuesAlert[$alertTime] = $this->lang['reminder'][$alertTime]; } $fld->setPossibleValues($possibleValuesAlert); $fld->setControlledElements([''=>[$fldEmail]], 'enable'); $fieldset3->addElement($fld); } elseif ($this->controller->getAction()=='update') { $fld=new \Engine\Form\Input\Datetime($this->lang['formFields']['alert'], 'alertDateTime', $this->values['alertDateTime']); $fieldset3->addElement($fld); } $fieldset3->addElement($fldEmail); $fieldset4 = \Engine\Form\Container\Fieldset::create($this->lang['fieldSet']['options']); $form->addContainer($fieldset4); $fld = new \Engine\Form\Input\Radio($this->lang['formFields']['access'], 'access', $this->values['access']); $accessList = []; foreach (['private', 'public'] as $access) { $accessList[$access] = $this->lang['access'][$access]; } $fld->setPossibleValues($accessList); $fieldset4->addElement($fld); if ($this->controller->getAction()=='insert') { $fld=new \App\Form\Input\Autocomplete_User($this->lang['formFields']['users'], 'idUser', $this->values['idUser']); $fld->setMandatory(true); $fieldset4->addElement($fld); } $form->addElement(new \Engine\Form\Input\Hidden('', $this->submitButtonName, 1)); return $form; } } 