Пример #1
0
 public function createComponentFormAddTerm($name)
 {
     Form::extensionMethod('addDatePicker', array($this, 'Form_addDatePicker'));
     Form::extensionMethod('addTimePicker', array($this, 'Form_addTimePicker'));
     Form::extensionMethod('addNumericUpDown', array($this, 'Form_addNumericUpDown'));
     $form = new LiveForm($this, $name);
     $form->getElementPrototype()->class('ajax');
     $form->addGroup('Exam room and time');
     $rooms = SchoolManager::getRooms();
     $rooms = array('0' => 'Please select') + $rooms;
     $form->addSelect('room', 'Room', $rooms)->addRule(Form::FILLED, 'Please select a room')->skipFirst();
     $form->addDatePicker('start_date', 'Date', 10)->addRule(Form::FILLED, 'Please select a starting date');
     $form->addTimePicker('start_date_time', 'Start time', 10)->addRule(Form::FILLED, 'Please select a starting time');
     $form->addGroup('Application deadline');
     $form->addDatePicker('deadline_date', 'Date', 10)->addRule(Form::FILLED, 'Please select an application deadline date');
     $form->addTimePicker('deadline_date_time', 'Time', 10)->addRule(Form::FILLED, 'Please select an application deadline time');
     $form->addGroup('Conditions');
     $form->addText('max_students', 'Student limit')->addRule(Form::FILLED, 'Please enter a student limit.')->addRule(Form::NUMERIC, 'Limit must be numeric');
     $form->addText('min_seminar_points', 'Minimum points')->addCondition(Form::FILLED)->addRule(Form::NUMERIC, 'Limit must be numeric');
     $form->addGroup('Note')->setOption('container', Html::el('fieldset')->class('no-label'));
     $form->addTextArea('note');
     $form->addHidden('course_id')->setValue($this->course_id);
     $form->addHidden('id');
     $form->addSubmit('btnSubmit', 'Save')->onClick[] = callback($this, 'FormAddTermSubmitted');
     if ($this->isSignalReceiver($this[$name])) {
         $this->template->show_popup = true;
     }
     if (isset($this->exam_id)) {
         $session = Environment::getSession('exam_terms_edit_form_' . $this->exam_id);
         if (isset($session['form_data'])) {
             $form_data = $session->form_data;
         } else {
             $form_data = ExamManager::getExam($this->exam_id);
             $form_data->start_date = $form_data->start_datetime;
             $form_data->deadline_date = $form_data->application_deadline;
             $form_data->start_date_time = $form_data->start_datetime;
             $form_data->deadline_date_time = $form_data->application_deadline;
             $session->form_data = $form_data;
         }
         $form->setDefaults($form_data);
         $form['id']->setValue($this->exam_id);
     }
     return $form;
 }
Пример #2
0
 public function createComponentFormAdminProfile($name)
 {
     $form = new LiveForm();
     $form->addGroup('My profile');
     foreach ($this->profile_data as $field => $value) {
         if ($field != 'password') {
             $form->addText($field, String::capitalize($field))->setValue($value);
         } else {
             $form->addPassword($field, 'Current ' . $field);
             $form->addPassword($field . '_new', 'New ' . $field);
             $form->addPassword($field . '_new_confirm', 'Confirm ' . $field);
         }
     }
     $form->addSubmit('btnSave', 'Save')->onClick[] = array($this, 'SaveProfile');
     return $form;
 }
Пример #3
0
 public function createComponentFormNewMenuItem($name)
 {
     $form = new LiveForm($this, $name);
     $form->addGroup('Add new item');
     $form->addText('title', 'Title')->addRule(Form::FILLED, 'Please enter a name.');
     $form->addRadioList('link_type', 'Link type', array('internal' => 'internal', 'external' => 'external'))->setDefaultValue('internal');
     $pages = $this->model('pages')->getPairs();
     $temp = array();
     if (isset($pages[""])) {
         $temp = $pages[""];
         unset($pages[""]);
     }
     $pages = array('none' => $temp) + $pages;
     unset($temp);
     $categories = $this->model('categories')->getPairs('slug', 'title');
     $items = array('homepagelink' => 'Link to Homepage');
     foreach (array('none' => 'none') + $categories as $cat_slug => $cat_title) {
         if ($cat_title != 'none') {
             $items[$cat_slug] = 'cat: ' . $cat_title;
         }
         if (isset($pages[$cat_title])) {
             foreach ($pages[$cat_title] as $page_title => $data) {
                 if ($cat_title == 'none') {
                     $items[$data->page_slug] = 'page ' . $page_title;
                 } else {
                     $items[$cat_slug . '/' . $data->page_slug] = 'article in ' . $cat_title . ': ' . $page_title;
                 }
             }
         }
     }
     $form->addSelect('internal_url', 'Page', $items)->addRule(Form::FILLED, 'Please select a page.');
     $form->addText('external_url', 'Link')->addConditionOn($form['link_type'], Form::EQUAL, 'external')->addRule(Form::FILLED, 'Please enter a link')->addRule(Form::URL, 'Please enter a valid link');
     $items = $this->model('menuItems')->getByMenuId($this->menu->id)->fetchPairs('id_level', 'title');
     $items = array_merge(array('0;0' => 'none'), $items);
     $form->addSelect('parent_data', 'Parent', $items);
     $form->addButton('btnClose', 'Close');
     $form->addSubmit('save', 'Add')->onClick[] = array($this, 'formNewMenuItemSubmitted');
     $form['save']->getControlPrototype()->class('ajax');
     return $form;
 }
Пример #4
0
 public function createComponentFormSearch($name)
 {
     $form = new LiveForm($this, $name);
     $renderer = $form->getRenderer();
     $renderer->wrappers['form']['container'] = Html::el('div')->id('search-form');
     $renderer->wrappers['controls']['container'] = null;
     $renderer->wrappers['pair']['container'] = null;
     $renderer->wrappers['label']['container'] = null;
     $renderer->wrappers['control']['container'] = null;
     $form->addGroup('Search')->setOption('container', Html::el('fieldset')->id('search'));
     $form->addText('search_query', '');
     $form->addSubmit('ok', 'GO!')->onClick[] = array($this, 'getSearchResults');
 }