]> git.mjollnir.org Git - moodle.git/commitdiff
New textarea profile field type
authorikawhero <ikawhero>
Sat, 28 Apr 2007 03:07:43 +0000 (03:07 +0000)
committerikawhero <ikawhero>
Sat, 28 Apr 2007 03:07:43 +0000 (03:07 +0000)
user/profile/field/textarea/define.class.php [new file with mode: 0644]
user/profile/field/textarea/field.class.php [new file with mode: 0644]

diff --git a/user/profile/field/textarea/define.class.php b/user/profile/field/textarea/define.class.php
new file mode 100644 (file)
index 0000000..f35f6de
--- /dev/null
@@ -0,0 +1,23 @@
+<?php  //$Id$
+
+class profile_define_textarea extends profile_define_base {
+
+    function define_form_specific(&$form) {
+        /// Default data
+        $form->addElement('htmleditor', 'defaultdata', get_string('profiledefaultdata', 'admin'));
+        $form->setType('defaultdata', PARAM_CLEAN);
+
+        /// Param 1 for textarea type is the number of columns
+        $form->addElement('text', 'param1', get_string('profilefieldcolumns', 'admin'), 'size="6"');
+        $form->setDefault('param1', 30);
+        $form->setType('param1', PARAM_INT);
+
+        /// Param 2 for text type is the number of rows
+        $form->addElement('text', 'param2', get_string('profilefieldrows', 'admin'), 'size="6"');
+        $form->setDefault('param2', 10);
+        $form->setType('param2', PARAM_INT);
+    }
+
+}
+
+?>
diff --git a/user/profile/field/textarea/field.class.php b/user/profile/field/textarea/field.class.php
new file mode 100644 (file)
index 0000000..11d3925
--- /dev/null
@@ -0,0 +1,16 @@
+<?php //$Id$
+
+class profile_field_textarea extends profile_field_base {
+
+    function edit_field_add(&$mform) {
+        $cols = $this->field->param1;
+        $rows = $this->field->param2;
+
+        /// Create the form field
+        $mform->addElement('htmleditor', $this->inputname, format_string($this->field->name), array('cols'=>$cols, 'rows'=>$rows));
+        $mform->setType($this->inputname, PARAM_CLEAN);
+    }
+
+}
+
+?>