MDL-21781 very basic cohorts UI
[moodle.git] / cohort / edit_form.php
CommitLineData
b980c56e
PS
1<?php
2
3// This file is part of Moodle - http://moodle.org/
4//
5// Moodle is free software: you can redistribute it and/or modify
6// it under the terms of the GNU General Public License as published by
7// the Free Software Foundation, either version 3 of the License, or
8// (at your option) any later version.
9//
10// Moodle is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
14//
15// You should have received a copy of the GNU General Public License
16// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
17
18/**
19 * Cohort related management functions, this file needs to be included manually.
20 *
21 * @package moodlecore
22 * @subpackage cohort
23 * @copyright 2010 Petr Skoda (info@skodak.org)
24 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
25 */
26
27
28require_once($CFG->dirroot.'/lib/formslib.php');
29
30class cohort_edit_form extends moodleform {
31
32 // Define the form
33 function definition () {
34 global $USER, $CFG, $COURSE;
35
36 $mform = $this->_form;
37 $editoroptions = $this->_customdata['editoroptions'];
38
39 $mform->addElement('text', 'name', get_string('name', 'cohort'), 'maxlength="254" size="50"');
40 $mform->addRule('name', get_string('required'), 'required', null, 'client');
41 $mform->setType('name', PARAM_MULTILANG);
42
43 $mform->addElement('text', 'idnumber', get_string('idnumber', 'cohort'), 'maxlength="254" size="50"');
44 $mform->setType('name', PARAM_RAW);
45
46 $mform->addElement('editor', 'description_editor', get_string('description', 'cohort'), null, $editoroptions);
47 $mform->setType('description_editor', PARAM_RAW);
48
49 $mform->addElement('hidden','id');
50 $mform->setType('id', PARAM_INT);
51
52 $mform->addElement('hidden','contextid');
53 $mform->setType('contextid', PARAM_INT);
54
55 $this->add_action_buttons();
56 }
57
58 function validation($data, $files) {
59 global $DB;
60
61 $errors = parent::validation($data, $files);
62 $textlib = textlib_get_instance();
63
64 $idnumber = trim($data['idnumber']);
65 if ($data['id']) {
66 //TODO: validate there are no idnumber
67 }
68
69 return $errors;
70 }
71}
72