adding some strings
[moodle-linuxchix.git] / user / profile / index_category_form.php
blob4264ebf9c13b15541d2628dff2734982c57afd08
1 <?php //$Id$
3 require_once($CFG->dirroot.'/lib/formslib.php');
5 class category_form extends moodleform {
7 // Define the form
8 function definition () {
9 global $USER, $CFG;
11 $mform =& $this->_form;
13 $strrequired = get_string('required');
15 /// Add some extra hidden fields
16 $mform->addElement('hidden', 'id');
17 $mform->addElement('hidden', 'action', 'editcategory');
19 $mform->addElement('text', 'name', get_string('profilecategoryname', 'admin'), 'maxlength="255" size="30"');
20 $mform->setType('name', PARAM_MULTILANG);
21 $mform->addRule('name', $strrequired, 'required', null, 'client');
23 $this->add_action_buttons(true);
25 } /// End of function
27 /// perform some moodle validation
28 function validation ($data) {
29 global $CFG;
31 $data = (object)$data;
32 $err = array();
34 $category = get_record('user_info_category', 'id', $data->id);
36 /// Check the name is unique
37 if ($category and ($category->name !== $data->name) and (record_exists('user_info_category', 'name', $data->name))) {
38 $err['name'] = get_string('profilecategorynamenotunique', 'admin');
41 if (count($err) == 0){
42 return true;
43 } else {
44 return $err;