Updated the 19 build version to 20101023
[moodle.git] / user / profile / index_field_form.php
blobe61848a09e622db3dae94bb64ab9337cf52cb5f1
1 <?php //$Id$
3 require_once($CFG->dirroot.'/lib/formslib.php');
5 class field_form extends moodleform {
7 var $field;
9 /// Define the form
10 function definition () {
11 global $CFG;
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);