$template = PATH_CORE . 'templates/xmlform.html'; $newContent = $G_FORM->getFields($template); //Returns the dependentFields's content $sendContent = array(); $r = 0; foreach ($dependentFields as $d) { $sendContent[$r] = new stdclass(); $sendContent[$r]->name = $d; $sendContent[$r]->content = null; foreach ($G_FORM->fields[$d] as $attribute => $value) { switch ($attribute) { case 'type': $sendContent[$r]->content->{$attribute} = $value; break; case 'options': $sendContent[$r]->content->{$attribute} = toJSArray($value); break; } } $sendContent[$r]->value = $G_FORM->values[$d]; $r++; } echo Bootstrap::json_encode($sendContent); function toJSArray($array) { $result = array(); foreach ($array as $k => $v) { $o = null; $o->key = $k; $o->value = $v; $result[] = $o;
break; } } $sendContent[$r]->value = isset($G_FORM->values[$d]) ? $G_FORM->values[$d] : ''; } } else { foreach ($G_FORM->fields[$_POST['grid']]->fields[$d] as $attribute => $value) { switch ($attribute) { case 'type': $sendContent[$r]->content->{$attribute} = $value; break; case 'options': if ($sendContent[$r]->content->type != "text" && $sendContent[$r]->content->type != "textarea") { $sendContent[$r]->content->{$attribute} = toJSArray($value); } else { $sendContent[$r]->content->{$attribute} = toJSArray(isset($value[$_POST["row"]]) ? array($value[$_POST["row"]]) : array()); } break; } } $sendContent[$r]->value = isset($G_FORM->values[$_POST['grid']][$_POST['row']][$d]) ? $G_FORM->values[$_POST['grid']][$_POST['row']][$d] : ''; } $r = $r + 1; } echo Bootstrap::json_encode($sendContent); function toJSArray($array, $type = '') { $result = array(); foreach ($array as $k => $v) { $o = NULL; $o->key = $k;