MDL-22388 Added some checks to kill these scripts dead with an unequivocal notice...
[moodle.git] / user / profile / index_field_form.php
1 <?php
3 if (!defined('MOODLE_INTERNAL')) {
4     die('Direct access to this script is forbidden.');    ///  It must be included from a Moodle page
5 }
7 require_once($CFG->dirroot.'/lib/formslib.php');
9 class field_form extends moodleform {
11     var $field;
13 /// Define the form
14     function definition () {
15         global $CFG;
17         $mform =& $this->_form;
19         /// Everything else is dependant on the data type
20         $datatype = $this->_customdata;
21         require_once($CFG->dirroot.'/user/profile/field/'.$datatype.'/define.class.php');
22         $newfield = 'profile_define_'.$datatype;
23         $this->field = new $newfield();
25         $strrequired = get_string('required');
27         /// Add some extra hidden fields
28         $mform->addElement('hidden', 'id');
29         $mform->setType('id', PARAM_INT);
30         $mform->addElement('hidden', 'action', 'editfield');
31         $mform->setType('action', PARAM_ACTION);
32         $mform->addElement('hidden', 'datatype', $datatype);
33         $mform->setType('datatype', PARAM_ALPHA);
35         $this->field->define_form($mform);
37         $this->add_action_buttons(true);
38     }
41 /// alter definition based on existing or submitted data
42     function definition_after_data () {
43         $mform =& $this->_form;
44         $this->field->define_after_data($mform);
45     }
48 /// perform some moodle validation
49     function validation($data, $files) {
50         return $this->field->define_validate($data, $files);
51     }
53     function editors() {
54         return $this->field->define_editors();
55     }
56 }