3 require_once($CFG->dirroot
.'/lib/formslib.php');
5 class field_form
extends moodleform
{
10 function definition () {
13 $mform =& $this->_form
;
15 /// Everything else is dependant on the data type
16 $datatype = $this->_customdata
;
17 require_once($CFG->dirroot
.'/user/profile/field/'.$datatype.'/define.class.php');
18 $newfield = 'profile_define_'.$datatype;
19 $this->field
= new $newfield();
21 $strrequired = get_string('required');
23 /// Add some extra hidden fields
24 $mform->addElement('hidden', 'id');
25 $mform->setType('id', PARAM_INT
);
26 $mform->addElement('hidden', 'action', 'editfield');
27 $mform->setType('action', PARAM_ACTION
);
28 $mform->addElement('hidden', 'datatype', $datatype);
29 $mform->setType('datatype', PARAM_ALPHA
);
31 $this->field
->define_form($mform);
33 $this->add_action_buttons(true);
37 /// alter definition based on existing or submitted data
38 function definition_after_data () {
39 $mform =& $this->_form
;
40 $this->field
->define_after_data($mform);
44 /// perform some moodle validation
45 function validation($data, $files) {
46 return $this->field
->define_validate($data, $files);