svn.diff

moyo, 07/01/2013 08:45 PM

Download (3.81 KB)

View differences:

inc/commondbtm.class.php (working copy)
2056 2056
      }
2057 2057

  
2058 2058
      if (!$this->isNewID($ID)) {
2059
         echo "<input type='hidden' name='id' value='$ID'>";
2059
         Html::fieldsToSubmit(array('id' => $ID));
2060 2060
      }
2061 2061
      echo "</td>";
2062 2062
      echo "</tr>\n";
inc/html.class.php (working copy)
4131 4131
                     Html::cleanInputText($fieldName), Html::parseAttributes($options));
4132 4132
   }
4133 4133

  
4134

  
4135
   static private function recursiveGetFieldsToSubmit($fields, $prefix = '') {
4136
      $result = array();
4137
      foreach ($fields as $field => $value) {
4138
         $name = $prefix.'['.$field.']';
4139
         if (is_array($value)) {
4140
            $result = array_merge($result, self::recursiveGetFieldsToSubmit($value, $name));
4141
         } else {
4142
            $result[$name] = $value;
4143
         }
4144
      }
4145
      return $result;
4146
   }
4147

  
4148

  
4149
   static function fieldsToSubmit(array $fields) {
4150

  
4151
      foreach ($fields as $field => $value) {
4152
         if (is_array($value)) {
4153
            foreach (self::recursiveGetFieldsToSubmit($value) as $subfield => $value) {
4154
               echo self::hidden($field.$subfield, array('value' => $value))."\n";
4155
            }
4156
         } else {
4157
            echo self::hidden($field, array('value' => $value))."\n";
4158
         }
4159
      }
4160

  
4161
   }
4162

  
4163

  
4134 4164
   /**
4135 4165
   * Creates a submit button element. This method will generate `<input />` elements that
4136 4166
   * can be used to submit, and reset forms by using $options. Image submits can be created by supplying an
inc/ticket.class.php (working copy)
3521 3521
         echo "<td colspan='2' class='center'>";
3522 3522

  
3523 3523
         if ($tt->isField('id') && ($tt->fields['id'] > 0)) {
3524
            echo "<input type='hidden' name='_tickettemplates_id' value='".$tt->fields['id']."'>";
3525
            echo "<input type='hidden' name='_predefined_fields'
3526
                   value=\"".Toolbox::prepareArrayForInput($predefined_fields)."\">";
3524
            Html::fieldsToSubmit(array('_tickettemplates_id' => $tt->fields['id'],
3525
                                       '_predefined_fields' => $predefined_fields);
3527 3526
         }
3528 3527
         echo "<input type='submit' name='add' value=\"".__s('Submit message')."\" class='submit'>";
3529 3528
         echo "</td></tr>";
......
3794 3793
                                          $values['itilcategories_id'], $values['entities_id']);
3795 3794

  
3796 3795
      // Predefined fields from template : reset them
3797
      if (isset($values['_predefined_fields'])) {
3798
         $values['_predefined_fields']
3799
                        = Toolbox::decodeArrayFromInput($values['_predefined_fields']);
3800
      } else {
3796
      if (!isset($values['_predefined_fields'])) {
3801 3797
         $values['_predefined_fields'] = array();
3802 3798
      }
3803 3799

  
......
4609 4605
            echo "<td class='tab_bg_2 center' colspan='4'>";
4610 4606
            echo "<input type='submit' name='add' value=\""._sx('button','Add')."\" class='submit'>";
4611 4607
            if ($tt->isField('id') && ($tt->fields['id'] > 0)) {
4612
               echo "<input type='hidden' name='_tickettemplates_id' value='".$tt->fields['id']."'>";
4613
               echo "<input type='hidden' name='_predefined_fields'
4614
                      value=\"".Toolbox::prepareArrayForInput($predefined_fields)."\">";
4608
               Html::fieldsToSubmit(array('_tickettemplates_id' => $tt->fields['id'],
4609
                                          '_predefined_fields' => $predefined_fields));
4615 4610
            }
4616 4611
         }
4617 4612
      }