no more modification of form outside the form class. All needed data are passed by...
authorAndreas Grabs <info@grabs-edv.de>
Thu, 8 Apr 2010 19:32:43 +0000 (19:32 +0000)
committerAndreas Grabs <info@grabs-edv.de>
Thu, 8 Apr 2010 19:32:43 +0000 (19:32 +0000)
17 files changed:
mod/feedback/edit_item.php
mod/feedback/item/captcha/captcha_form.php
mod/feedback/item/captcha/lib.php
mod/feedback/item/info/info_form.php
mod/feedback/item/info/lib.php
mod/feedback/item/label/label_form.php
mod/feedback/item/label/lib.php
mod/feedback/item/multichoice/lib.php
mod/feedback/item/multichoice/multichoice_form.php
mod/feedback/item/multichoicerated/lib.php
mod/feedback/item/multichoicerated/multichoicerated_form.php
mod/feedback/item/numeric/lib.php
mod/feedback/item/numeric/numeric_form.php
mod/feedback/item/textarea/lib.php
mod/feedback/item/textarea/textarea_form.php
mod/feedback/item/textfield/lib.php
mod/feedback/item/textfield/textfield_form.php

index 291c172..da88fc7 100644 (file)
@@ -84,22 +84,8 @@ if($id and $item = $DB->get_record('feedback_item', array('id'=>$id))) {
 
 require_once($CFG->dirroot.'/mod/feedback/item/'.$typ.'/lib.php');
 
-//new formdefinition
 $itemclass = 'feedback_item_'.$typ;
 $itemobj = new $itemclass();
-$item_form = &$itemobj->show_edit($item);
-
-$i_form = &$item_form->get_item_form();
-// $i_form->addElement('header', 'general', 'Titel');
-$i_form->addElement('hidden', 'cmid', $cmid);
-$i_form->setType('cmid', PARAM_INT);
-$i_form->addElement('hidden', 'id', isset($item->id)?$item->id:'');
-$i_form->setType('id', PARAM_INT);
-$i_form->addElement('hidden', 'typ', $typ);
-$i_form->setType('typ', PARAM_ALPHA);
-$i_form->addElement('hidden', 'feedbackid', $feedback->id);
-$i_form->setType('feedbackid', PARAM_INT);
-
 
 $lastposition = $DB->count_records('feedback_item', array('feedback'=>$feedback->id));
 if($position == -1){
@@ -109,27 +95,14 @@ if($position == -1){
     $i_formselect_last = $lastposition;
     $i_formselect_value = $item->position;
 }
-$i_formselect = $i_form->addElement('select',
-                                    'position',
-                                    get_string('position', 'feedback').'&nbsp;',
-                                    array_slice(range(0,$i_formselect_last),1,$i_formselect_last,true));
-$i_formselect->setValue($i_formselect_value);
-
-$buttonarray = array();
-if(!empty($item->id)){
-    $i_form->addElement('hidden', 'updateitem', '1');
-    $i_form->setType('updateitem', PARAM_INT);
-    // $i_form->addElement('submit', 'update_item', get_string('update_item', 'feedback'));
-    $buttonarray[] = &$i_form->createElement('submit', 'update_item', get_string('update_item', 'feedback'));
-}else{
-    $i_form->addElement('hidden', 'saveitem', '1');
-    $i_form->setType('saveitem', PARAM_INT);
-    // $i_form->addElement('submit', 'save_item', get_string('save_item', 'feedback'));
-    $buttonarray[] = &$i_form->createElement('submit', 'save_item', get_string('save_item', 'feedback'));
-}
-// $i_form->addElement('cancel');
-$buttonarray[] = &$i_form->createElement('cancel');
-$i_form->addGroup($buttonarray, 'buttonar', '', array(' '), false);
+$positionlist = array_slice(range(0,$i_formselect_last),1,$i_formselect_last,true);
+
+$commonarams = array('cmid'=>$cmid,
+                     'id'=>isset($item->id) ? $item->id : NULL,
+                     'typ'=>$typ,
+                     'feedbackid'=>$feedback->id);
+                     
+$item_form = &$itemobj->show_edit($item, $commonarams, $positionlist, $i_formselect_value);
 
 ////////////////////////////////////////////////////////////////////////////////////
 $item_form->set_data($item);
index dc21fa3..ad9bb2b 100644 (file)
@@ -23,6 +23,45 @@ class feedback_captcha_form extends feedback_item_form {
                                             get_string('count_of_nums', 'feedback').'&nbsp;',
                                             array_slice(range(0,10),3,10,true));
 
+        
+        ////////////////////////////////////////////////////////////////////////
+        //the following is used in all itemforms
+        ////////////////////////////////////////////////////////////////////////
+        $item = $this->_customdata['item'];
+        $common = $this->_customdata['common'];
+
+        $mform->addElement('hidden', 'cmid', $common['cmid']);
+        $mform->setType('cmid', PARAM_INT);
+        $mform->addElement('hidden', 'id', $common['id']);
+        $mform->setType('id', PARAM_INT);
+        $mform->addElement('hidden', 'typ', $common['typ']);
+        $mform->setType('typ', PARAM_ALPHA);
+        $mform->addElement('hidden', 'feedbackid', $common['feedbackid']);
+        $mform->setType('feedbackid', PARAM_INT);
+
+        $position_select = $mform->addElement('select',
+                                            'position',
+                                            get_string('position', 'feedback').'&nbsp;',
+                                            $this->_customdata['positionlist']);
+        $position_select->setValue($this->_customdata['position']);
+        
+
+        $buttonarray = array();
+        if(!empty($item->id)){
+            $mform->addElement('hidden', 'updateitem', '1');
+            $mform->setType('updateitem', PARAM_INT);
+            // $i_form->addElement('submit', 'update_item', get_string('update_item', 'feedback'));
+            $buttonarray[] = &$mform->createElement('submit', 'update_item', get_string('update_item', 'feedback'));
+        }else{
+            $mform->addElement('hidden', 'saveitem', '1');
+            $mform->setType('saveitem', PARAM_INT);
+            // $i_form->addElement('submit', 'save_item', get_string('save_item', 'feedback'));
+            $buttonarray[] = &$mform->createElement('submit', 'save_item', get_string('save_item', 'feedback'));
+        }
+        // $i_form->addElement('cancel');
+        $buttonarray[] = &$mform->createElement('cancel');
+        $mform->addGroup($buttonarray, 'buttonar', '&nbsp;', array(' '), false);
+
     }
 }
 
index f178348..fb74f8a 100644 (file)
@@ -8,12 +8,22 @@ class feedback_item_captcha extends feedback_item_base {
 
     }
 
-    function show_edit($item) {
+/**
+ * Build the editform for the item
+ *
+ * @global object
+ * @param object $item the instance of the recordset feedback_item
+ * @param array $commonparams all hidden values needed in the form
+ * @param array $positionlist this array build the selection list for itemposition
+ * @param int $position the current itemposition
+ * @return object instance of the built form
+ */
+    function show_edit($item, $commonparams, $positionlist, $position) {
         global $CFG;
 
         require_once('captcha_form.php');
 
-        $item_form = new feedback_captcha_form();
+        $item_form = new feedback_captcha_form('edit_item.php', array('item'=>$item, 'common'=>$commonparams, 'positionlist'=>$positionlist, 'position'=>$position));
 
         $item->presentation = empty($item->presentation) ? 3 : $item->presentation;
         $item->name = empty($item->name) ? '' : $item->name;
index 5ee5e59..6c7d42a 100644 (file)
@@ -25,6 +25,45 @@ class feedback_info_form extends feedback_item_form {
         $options[3]  = get_string('coursecategory', 'feedback');
         $this->infotype = &$mform->addElement('select', 'infotype', get_string('infotype', 'feedback'), $options);
 
+        
+        ////////////////////////////////////////////////////////////////////////
+        //the following is used in all itemforms
+        ////////////////////////////////////////////////////////////////////////
+        $item = $this->_customdata['item'];
+        $common = $this->_customdata['common'];
+
+        $mform->addElement('hidden', 'cmid', $common['cmid']);
+        $mform->setType('cmid', PARAM_INT);
+        $mform->addElement('hidden', 'id', $common['id']);
+        $mform->setType('id', PARAM_INT);
+        $mform->addElement('hidden', 'typ', $common['typ']);
+        $mform->setType('typ', PARAM_ALPHA);
+        $mform->addElement('hidden', 'feedbackid', $common['feedbackid']);
+        $mform->setType('feedbackid', PARAM_INT);
+
+        $position_select = $mform->addElement('select',
+                                            'position',
+                                            get_string('position', 'feedback').'&nbsp;',
+                                            $this->_customdata['positionlist']);
+        $position_select->setValue($this->_customdata['position']);
+        
+
+        $buttonarray = array();
+        if(!empty($item->id)){
+            $mform->addElement('hidden', 'updateitem', '1');
+            $mform->setType('updateitem', PARAM_INT);
+            // $i_form->addElement('submit', 'update_item', get_string('update_item', 'feedback'));
+            $buttonarray[] = &$mform->createElement('submit', 'update_item', get_string('update_item', 'feedback'));
+        }else{
+            $mform->addElement('hidden', 'saveitem', '1');
+            $mform->setType('saveitem', PARAM_INT);
+            // $i_form->addElement('submit', 'save_item', get_string('save_item', 'feedback'));
+            $buttonarray[] = &$mform->createElement('submit', 'save_item', get_string('save_item', 'feedback'));
+        }
+        // $i_form->addElement('cancel');
+        $buttonarray[] = &$mform->createElement('cancel');
+        $mform->addGroup($buttonarray, 'buttonar', '&nbsp;', array(' '), false);
+
     }
 }
 
index b6a7a12..968711b 100644 (file)
@@ -8,12 +8,12 @@ class feedback_item_info extends feedback_item_base {
 
     }
 
-    function &show_edit($item) {
+    function show_edit($item, $commonparams, $positionlist, $position) {
         global $CFG;
 
         require_once('info_form.php');
 
-        $item_form = new feedback_info_form();
+        $item_form = new feedback_info_form('edit_item.php', array('item'=>$item, 'common'=>$commonparams, 'positionlist'=>$positionlist, 'position'=>$position));
 
         $item->presentation = empty($item->presentation) ? '' : $item->presentation;
         $item->name = empty($item->name) ? '' : htmlspecialchars($item->name);
index c577e6c..e68c72e 100644 (file)
@@ -15,6 +15,46 @@ class feedback_label_form extends feedback_item_form {
         $mform->setType('itemname', PARAM_INT);
         $mform->addElement('editor', 'presentation', '', null, null);
         $mform->setType('presentation', PARAM_CLEANHTML);
+    
+        
+        ////////////////////////////////////////////////////////////////////////
+        //the following is used in all itemforms
+        ////////////////////////////////////////////////////////////////////////
+        $item = $this->_customdata['item'];
+        $common = $this->_customdata['common'];
+
+        $mform->addElement('hidden', 'cmid', $common['cmid']);
+        $mform->setType('cmid', PARAM_INT);
+        $mform->addElement('hidden', 'id', $common['id']);
+        $mform->setType('id', PARAM_INT);
+        $mform->addElement('hidden', 'typ', $common['typ']);
+        $mform->setType('typ', PARAM_ALPHA);
+        $mform->addElement('hidden', 'feedbackid', $common['feedbackid']);
+        $mform->setType('feedbackid', PARAM_INT);
+
+        $position_select = $mform->addElement('select',
+                                            'position',
+                                            get_string('position', 'feedback').'&nbsp;',
+                                            $this->_customdata['positionlist']);
+        $position_select->setValue($this->_customdata['position']);
+        
+
+        $buttonarray = array();
+        if(!empty($item->id)){
+            $mform->addElement('hidden', 'updateitem', '1');
+            $mform->setType('updateitem', PARAM_INT);
+            // $i_form->addElement('submit', 'update_item', get_string('update_item', 'feedback'));
+            $buttonarray[] = &$mform->createElement('submit', 'update_item', get_string('update_item', 'feedback'));
+        }else{
+            $mform->addElement('hidden', 'saveitem', '1');
+            $mform->setType('saveitem', PARAM_INT);
+            // $i_form->addElement('submit', 'save_item', get_string('save_item', 'feedback'));
+            $buttonarray[] = &$mform->createElement('submit', 'save_item', get_string('save_item', 'feedback'));
+        }
+        // $i_form->addElement('cancel');
+        $buttonarray[] = &$mform->createElement('cancel');
+        $mform->addGroup($buttonarray, 'buttonar', '&nbsp;', array(' '), false);
+
     }
 
     function get_data() {
@@ -26,7 +66,9 @@ class feedback_label_form extends feedback_item_form {
     }
 
     function set_data($data) {
-        $data->presentation = array('text'=>$data->presentation, 'format'=>FORMAT_HTML, 'itemid'=>0);
+        if(isset($data->presentation)) {
+            $data->presentation = array('text'=>$data->presentation, 'format'=>FORMAT_HTML, 'itemid'=>0);
+        }
         return parent::set_data($data);
     }
 }
index 7ee97fd..a4b1bec 100644 (file)
@@ -8,12 +8,12 @@ class feedback_item_label extends feedback_item_base {
 
     }
 
-    function show_edit($item) {
+    function show_edit($item, $commonparams, $positionlist, $position) {
         global $CFG;
 
         require_once('label_form.php');
 
-        $item_form = new feedback_label_form();
+        $item_form = new feedback_label_form('edit_item.php', array('item'=>$item, 'common'=>$commonparams, 'positionlist'=>$positionlist, 'position'=>$position));
         
         return $item_form;
     }
index d17b5f9..fcf596a 100644 (file)
@@ -12,12 +12,12 @@ class feedback_item_multichoice extends feedback_item_base {
 
     }
 
-    function show_edit($item) {
+    function show_edit($item, $commonparams, $positionlist, $position) {
         global $CFG;
 
         require_once('multichoice_form.php');
 
-        $item_form = new feedback_multichoice_form();
+        $item_form = new feedback_multichoice_form('edit_item.php', array('item'=>$item, 'common'=>$commonparams, 'positionlist'=>$positionlist, 'position'=>$position));
 
         $item->presentation = empty($item->presentation) ? '' : $item->presentation;
         $item->name = empty($item->name) ? '' : $item->name;
index 2bca934..65353fd 100644 (file)
@@ -37,6 +37,45 @@ class feedback_multichoice_form extends feedback_item_form {
 
         $this->values = $mform->addElement('textarea', 'itemvalues', '', 'wrap="virtual" rows="10" cols="65"');
 
+        
+        ////////////////////////////////////////////////////////////////////////
+        //the following is used in all itemforms
+        ////////////////////////////////////////////////////////////////////////
+        $item = $this->_customdata['item'];
+        $common = $this->_customdata['common'];
+
+        $mform->addElement('hidden', 'cmid', $common['cmid']);
+        $mform->setType('cmid', PARAM_INT);
+        $mform->addElement('hidden', 'id', $common['id']);
+        $mform->setType('id', PARAM_INT);
+        $mform->addElement('hidden', 'typ', $common['typ']);
+        $mform->setType('typ', PARAM_ALPHA);
+        $mform->addElement('hidden', 'feedbackid', $common['feedbackid']);
+        $mform->setType('feedbackid', PARAM_INT);
+
+        $position_select = $mform->addElement('select',
+                                            'position',
+                                            get_string('position', 'feedback').'&nbsp;',
+                                            $this->_customdata['positionlist']);
+        $position_select->setValue($this->_customdata['position']);
+        
+
+        $buttonarray = array();
+        if(!empty($item->id)){
+            $mform->addElement('hidden', 'updateitem', '1');
+            $mform->setType('updateitem', PARAM_INT);
+            // $i_form->addElement('submit', 'update_item', get_string('update_item', 'feedback'));
+            $buttonarray[] = &$mform->createElement('submit', 'update_item', get_string('update_item', 'feedback'));
+        }else{
+            $mform->addElement('hidden', 'saveitem', '1');
+            $mform->setType('saveitem', PARAM_INT);
+            // $i_form->addElement('submit', 'save_item', get_string('save_item', 'feedback'));
+            $buttonarray[] = &$mform->createElement('submit', 'save_item', get_string('save_item', 'feedback'));
+        }
+        // $i_form->addElement('cancel');
+        $buttonarray[] = &$mform->createElement('cancel');
+        $mform->addGroup($buttonarray, 'buttonar', '&nbsp;', array(' '), false);
+
     }
 }
 
index 1e0f51d..85b1ed6 100644 (file)
@@ -17,12 +17,12 @@ class feedback_item_multichoicerated extends feedback_item_base {
 
     }
 
-    function show_edit($item) {
+    function show_edit($item, $commonparams, $positionlist, $position) {
         global $CFG;
 
         require_once('multichoicerated_form.php');
 
-        $item_form = new feedback_multichoicerated_form();
+        $item_form = new feedback_multichoicerated_form('edit_item.php', array('item'=>$item, 'common'=>$commonparams, 'positionlist'=>$positionlist, 'position'=>$position));
 
         $item->presentation = empty($item->presentation) ? '' : $item->presentation;
         $item->name = empty($item->name) ? '' : $item->name;
index c8b497a..6939107 100644 (file)
@@ -36,6 +36,45 @@ class feedback_multichoicerated_form extends feedback_item_form {
 
         $this->values = $mform->addElement('textarea', 'itemvalues', '', 'wrap="virtual" rows="10" cols="65"');
 
+        
+        ////////////////////////////////////////////////////////////////////////
+        //the following is used in all itemforms
+        ////////////////////////////////////////////////////////////////////////
+        $item = $this->_customdata['item'];
+        $common = $this->_customdata['common'];
+
+        $mform->addElement('hidden', 'cmid', $common['cmid']);
+        $mform->setType('cmid', PARAM_INT);
+        $mform->addElement('hidden', 'id', $common['id']);
+        $mform->setType('id', PARAM_INT);
+        $mform->addElement('hidden', 'typ', $common['typ']);
+        $mform->setType('typ', PARAM_ALPHA);
+        $mform->addElement('hidden', 'feedbackid', $common['feedbackid']);
+        $mform->setType('feedbackid', PARAM_INT);
+
+        $position_select = $mform->addElement('select',
+                                            'position',
+                                            get_string('position', 'feedback').'&nbsp;',
+                                            $this->_customdata['positionlist']);
+        $position_select->setValue($this->_customdata['position']);
+        
+
+        $buttonarray = array();
+        if(!empty($item->id)){
+            $mform->addElement('hidden', 'updateitem', '1');
+            $mform->setType('updateitem', PARAM_INT);
+            // $i_form->addElement('submit', 'update_item', get_string('update_item', 'feedback'));
+            $buttonarray[] = &$mform->createElement('submit', 'update_item', get_string('update_item', 'feedback'));
+        }else{
+            $mform->addElement('hidden', 'saveitem', '1');
+            $mform->setType('saveitem', PARAM_INT);
+            // $i_form->addElement('submit', 'save_item', get_string('save_item', 'feedback'));
+            $buttonarray[] = &$mform->createElement('submit', 'save_item', get_string('save_item', 'feedback'));
+        }
+        // $i_form->addElement('cancel');
+        $buttonarray[] = &$mform->createElement('cancel');
+        $mform->addGroup($buttonarray, 'buttonar', '&nbsp;', array(' '), false);
+
     }
 }
 
index b723373..049a977 100644 (file)
@@ -18,12 +18,12 @@ class feedback_item_numeric extends feedback_item_base {
         }
     }
 
-    function show_edit($item) {
+    function show_edit($item, $commonparams, $positionlist, $position) {
         global $CFG;
 
         require_once('numeric_form.php');
 
-        $item_form = new feedback_numeric_form();
+        $item_form = new feedback_numeric_form('edit_item.php', array('item'=>$item, 'common'=>$commonparams, 'positionlist'=>$positionlist, 'position'=>$position));
 
         $item->presentation = empty($item->presentation) ? '' : $item->presentation;
         $item->name = empty($item->name) ? '' : $item->name;
index 41d1e38..f73ad7e 100644 (file)
@@ -23,6 +23,45 @@ class feedback_numeric_form extends feedback_item_form {
 
         $this->selectto = $mform->addElement('text', 'numericrangeto', get_string('numeric_range_to', 'feedback'), array('size="10"','maxlength="10"'));
 
+        
+        ////////////////////////////////////////////////////////////////////////
+        //the following is used in all itemforms
+        ////////////////////////////////////////////////////////////////////////
+        $item = $this->_customdata['item'];
+        $common = $this->_customdata['common'];
+
+        $mform->addElement('hidden', 'cmid', $common['cmid']);
+        $mform->setType('cmid', PARAM_INT);
+        $mform->addElement('hidden', 'id', $common['id']);
+        $mform->setType('id', PARAM_INT);
+        $mform->addElement('hidden', 'typ', $common['typ']);
+        $mform->setType('typ', PARAM_ALPHA);
+        $mform->addElement('hidden', 'feedbackid', $common['feedbackid']);
+        $mform->setType('feedbackid', PARAM_INT);
+
+        $position_select = $mform->addElement('select',
+                                            'position',
+                                            get_string('position', 'feedback').'&nbsp;',
+                                            $this->_customdata['positionlist']);
+        $position_select->setValue($this->_customdata['position']);
+        
+
+        $buttonarray = array();
+        if(!empty($item->id)){
+            $mform->addElement('hidden', 'updateitem', '1');
+            $mform->setType('updateitem', PARAM_INT);
+            // $i_form->addElement('submit', 'update_item', get_string('update_item', 'feedback'));
+            $buttonarray[] = &$mform->createElement('submit', 'update_item', get_string('update_item', 'feedback'));
+        }else{
+            $mform->addElement('hidden', 'saveitem', '1');
+            $mform->setType('saveitem', PARAM_INT);
+            // $i_form->addElement('submit', 'save_item', get_string('save_item', 'feedback'));
+            $buttonarray[] = &$mform->createElement('submit', 'save_item', get_string('save_item', 'feedback'));
+        }
+        // $i_form->addElement('cancel');
+        $buttonarray[] = &$mform->createElement('cancel');
+        $mform->addGroup($buttonarray, 'buttonar', '&nbsp;', array(' '), false);
+
     }
 }
 
index 75010a5..5dbf421 100644 (file)
@@ -8,12 +8,12 @@ class feedback_item_textarea extends feedback_item_base {
 
     }
 
-    function show_edit($item) {
+    function show_edit($item, $commonparams, $positionlist, $position) {
         global $CFG;
 
         require_once('textarea_form.php');
 
-        $item_form = new feedback_textarea_form();
+        $item_form = new feedback_textarea_form('edit_item.php', array('item'=>$item, 'common'=>$commonparams, 'positionlist'=>$positionlist, 'position'=>$position));
 
         $item->presentation = empty($item->presentation) ? '' : $item->presentation;
         $item->name = empty($item->name) ? '' : $item->name;
index 57ff0d0..1bc5c5c 100644 (file)
@@ -29,6 +29,45 @@ class feedback_textarea_form extends feedback_item_form {
                                             get_string('textarea_height', 'feedback').'&nbsp;',
                                             array_slice(range(0,40),5,40,true));
 
+        
+        ////////////////////////////////////////////////////////////////////////
+        //the following is used in all itemforms
+        ////////////////////////////////////////////////////////////////////////
+        $item = $this->_customdata['item'];
+        $common = $this->_customdata['common'];
+
+        $mform->addElement('hidden', 'cmid', $common['cmid']);
+        $mform->setType('cmid', PARAM_INT);
+        $mform->addElement('hidden', 'id', $common['id']);
+        $mform->setType('id', PARAM_INT);
+        $mform->addElement('hidden', 'typ', $common['typ']);
+        $mform->setType('typ', PARAM_ALPHA);
+        $mform->addElement('hidden', 'feedbackid', $common['feedbackid']);
+        $mform->setType('feedbackid', PARAM_INT);
+
+        $position_select = $mform->addElement('select',
+                                            'position',
+                                            get_string('position', 'feedback').'&nbsp;',
+                                            $this->_customdata['positionlist']);
+        $position_select->setValue($this->_customdata['position']);
+        
+
+        $buttonarray = array();
+        if(!empty($item->id)){
+            $mform->addElement('hidden', 'updateitem', '1');
+            $mform->setType('updateitem', PARAM_INT);
+            // $i_form->addElement('submit', 'update_item', get_string('update_item', 'feedback'));
+            $buttonarray[] = &$mform->createElement('submit', 'update_item', get_string('update_item', 'feedback'));
+        }else{
+            $mform->addElement('hidden', 'saveitem', '1');
+            $mform->setType('saveitem', PARAM_INT);
+            // $i_form->addElement('submit', 'save_item', get_string('save_item', 'feedback'));
+            $buttonarray[] = &$mform->createElement('submit', 'save_item', get_string('save_item', 'feedback'));
+        }
+        // $i_form->addElement('cancel');
+        $buttonarray[] = &$mform->createElement('cancel');
+        $mform->addGroup($buttonarray, 'buttonar', '&nbsp;', array(' '), false);
+
     }
 }
 
index e703e58..6a01365 100644 (file)
@@ -8,12 +8,12 @@ class feedback_item_textfield extends feedback_item_base {
 
     }
 
-    function show_edit($item) {
+    function show_edit($item, $commonparams, $positionlist, $position) {
         global $CFG;
 
         require_once('textfield_form.php');
 
-        $item_form = new feedback_textfield_form();
+        $item_form = new feedback_textfield_form('edit_item.php', array('item'=>$item, 'common'=>$commonparams, 'positionlist'=>$positionlist, 'position'=>$position));
 
         $item->presentation = empty($item->presentation) ? '' : $item->presentation;
         $item->name = empty($item->name) ? '' : $item->name;
index 4d1664c..54088ab 100644 (file)
@@ -29,6 +29,45 @@ class feedback_textfield_form extends feedback_item_form {
                                             get_string('textfield_maxlength', 'feedback').'&nbsp;',
                                             array_slice(range(0,255),5,255,true));
 
+        
+        ////////////////////////////////////////////////////////////////////////
+        //the following is used in all itemforms
+        ////////////////////////////////////////////////////////////////////////
+        $item = $this->_customdata['item'];
+        $common = $this->_customdata['common'];
+
+        $mform->addElement('hidden', 'cmid', $common['cmid']);
+        $mform->setType('cmid', PARAM_INT);
+        $mform->addElement('hidden', 'id', $common['id']);
+        $mform->setType('id', PARAM_INT);
+        $mform->addElement('hidden', 'typ', $common['typ']);
+        $mform->setType('typ', PARAM_ALPHA);
+        $mform->addElement('hidden', 'feedbackid', $common['feedbackid']);
+        $mform->setType('feedbackid', PARAM_INT);
+
+        $position_select = $mform->addElement('select',
+                                            'position',
+                                            get_string('position', 'feedback').'&nbsp;',
+                                            $this->_customdata['positionlist']);
+        $position_select->setValue($this->_customdata['position']);
+        
+
+        $buttonarray = array();
+        if(!empty($item->id)){
+            $mform->addElement('hidden', 'updateitem', '1');
+            $mform->setType('updateitem', PARAM_INT);
+            // $i_form->addElement('submit', 'update_item', get_string('update_item', 'feedback'));
+            $buttonarray[] = &$mform->createElement('submit', 'update_item', get_string('update_item', 'feedback'));
+        }else{
+            $mform->addElement('hidden', 'saveitem', '1');
+            $mform->setType('saveitem', PARAM_INT);
+            // $i_form->addElement('submit', 'save_item', get_string('save_item', 'feedback'));
+            $buttonarray[] = &$mform->createElement('submit', 'save_item', get_string('save_item', 'feedback'));
+        }
+        // $i_form->addElement('cancel');
+        $buttonarray[] = &$mform->createElement('cancel');
+        $mform->addGroup($buttonarray, 'buttonar', '&nbsp;', array(' '), false);
+
     }
 }