]> git.mjollnir.org Git - moodle.git/commitdiff
Various changes for GUI.
authorikawhero <ikawhero>
Fri, 12 Jan 2007 01:01:57 +0000 (01:01 +0000)
committerikawhero <ikawhero>
Fri, 12 Jan 2007 01:01:57 +0000 (01:01 +0000)
user/profile/field/menu/field.class.php
user/profile/field/text/field.class.php

index 02a177cb8c7da1d53434c56bb8e67e924adf23f7..ad5df466708f7ebdfc374a42adec93f3fc739ff1 100644 (file)
@@ -47,6 +47,32 @@ class profile_field_menu extends profile_field_base {
             return $this->options[$data];
         }
     }
+
+    function edit_field_specific(&$form) {
+        /// Param 1 for menu type contains the options
+        $form->addElement('textarea', 'param1', get_string('profilemenuoptions'));
+        $form->setType('param1', PARAM_MULTILANG);
+        
+        /// Default data
+        $form->addElement('text', 'defaultdata', get_string('profiledefaultdata'), 'size="30"');
+        $form->setType('defaultdata', PARAM_MULTILANG);
+    }
+
+    function edit_validate_specific($data) {
+        $err = array();
+        
+        /// Check that we have at least 2 options
+        if (($options = explode("\n", $data->param1)) === false) {
+            $err['param1'] = get_string('profilemenunooptions');
+        } elseif (count($options) < 2) {
+            $err['param1'] = get_string('profilemenuoptions');
+            
+        /// Check the default data exists in the options
+        } elseif (!empty($data->defaultdata) and !in_array($data->defaultdata, $options)) {
+            $err['defaultdata'] = get_string('profilemenudefaultnotinoptions');
+        }
+        return $err;        
+    }
 }
 
 ?>
index fa2f53406552c7abec71f37179c7fcbb87b6b8ac..96a5cb78ac0d5124eb804ffe5ae1fa447f7fa0ae 100644 (file)
@@ -7,7 +7,7 @@ class profile_field_text extends profile_field_base {
         $size = (empty($this->field->param1)) ? '30' : $this->field->param1;
 
         /// Param 2 for text type is the maxlength of the field
-        $maxlength = (empty($this->field->param2)) ? '254' : $this->field->param2;
+        $maxlength = (empty($this->field->param2)) ? '2048' : $this->field->param2;
 
         /// Create the form field
         $form->addElement('text', $this->fieldname, $this->field->name, 'maxlength="'.$maxlength.'" size="'.$size.'" ');
@@ -17,6 +17,21 @@ class profile_field_text extends profile_field_base {
     function set_data_type() {
         $this->datatype = 'text';
     }
+
+    function edit_field_specific(&$form) {
+        /// Default data
+        $form->addElement('text', 'defaultdata', get_string('profiledefaultdata'), 'size="30"');
+        $form->setType('defaultdata', PARAM_MULTILANG);
+
+        /// Param 1 for text type is the size of the field
+        $form->addElement('text', 'param1', get_string('profilefieldsize'), 'size="6"');
+        $form->setType('param1', PARAM_INT);
+        
+        /// Param 2 for text type is the maxlength of the field
+        $form->addElement('text', 'param2', get_string('profilefieldmaxlength'), 'size="6"');
+        $form->setType('param2', PARAM_INT);
+    }
+
 }
 
 ?>