Commit 91fb4407 authored by Hugo Leisink's avatar Hugo Leisink

Update form_script.php

parent 41a80dfc
......@@ -96,27 +96,30 @@
$elements = array_reverse($this->elements, true);
foreach ($elements as $elem_id => $element) {
$message = new message($post[$elem_id]);
$value = $message->unescaped_output();
switch ($element["type"]) {
case "line":
case "email":
case "number":
$item = "<input type=\"text\" id=\"".$elem_id."\" name=\"".$elem_id."\" value=\"".$post[$elem_id]."\" class=\"form-control\" >\n";
$item = "<input type=\"text\" id=\"".$elem_id."\" name=\"".$elem_id."\" value=\"".$value."\" class=\"form-control\" >\n";
break;
case "text";
$item = "<textarea id=\"".$elem_id."\" name=\"".$elem_id."\" class=\"form-control\">".$post[$elem_id]."</textarea>\n";
$item = "<textarea id=\"".$elem_id."\" name=\"".$elem_id."\" class=\"form-control\">".$value."</textarea>\n";
break;
case "checkbox":
$item = "<input type=\"checkbox\" id=\"".$elem_id."\" name=\"".$elem_id."\"".(is_true($post[$elem_id]) ? " checked" : "")." />\n";
$item = "<input type=\"checkbox\" id=\"".$elem_id."\" name=\"".$elem_id."\"".(is_true($value) ? " checked" : "")." />\n";
break;
case "choice":
list($element["label"], $answers) = explode(":", $element["label"], 2);
$answers = explode("/", $answers);
$item = "<select id=\"".$elem_id."\" name=\"".$elem_id."\" class=\"form-control\">\n";
if ($element["required"] == false) {
$item .= "<option".($post[$elem_id] == "" ? " selected" : "")."></option>\n";
$item .= "<option".($value == "" ? " selected" : "")."></option>\n";
}
foreach ($answers as $answer) {
$item .= "<option".($post[$elem_id] == $answer ? " selected" : "").">".$answer."</option>\n";
$item .= "<option".($value == $answer ? " selected" : "").">".$answer."</option>\n";
}
$item .= "</select>\n";
break;
......@@ -124,7 +127,7 @@
$this->view->add_javascript("jquery/jquery-ui.js");
$this->view->add_javascript("banshee/datepicker.js");
$this->view->add_css("jquery/jquery-ui.css");
$item = "<input type=\"text\" id=\"".$elem_id."\" name=\"".$elem_id."\" value=\"".$post[$elem_id]."\" class=\"form-control datepicker\" >\n";
$item = "<input type=\"text\" id=\"".$elem_id."\" name=\"".$elem_id."\" value=\"".$value."\" class=\"form-control datepicker\" >\n";
break;
default:
$item = "<div>Unknown form element defined.</div>\n";
......@@ -199,7 +202,11 @@
if ($element["type"] == "choice") {
list($element["label"], $answers) = explode(":", $element["label"], 2);
}
$result .= sprintf("<tr><td>%s:</td><td>%s</td></tr>\n", $element["label"], $post[$elem_id]);
$message = new message($post[$elem_id]);
$value = $message->unescaped_output();
$result .= sprintf("<tr><td>%s:</td><td>%s</td></tr>\n", $element["label"], $value);
}
$result .= "</table>\n";
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment