From 6e923629e055fabaf0672014ccb4162a02d0b3bb Mon Sep 17 00:00:00 2001 From: Sven Slootweg Date: Sat, 16 Feb 2013 02:33:39 +0100 Subject: [PATCH] Resolve conflicting variable name with 'value' parameter for input elements, and add support for 'id' parameter overrides --- class.templater.php | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/class.templater.php b/class.templater.php index 0c41d1a..16495ef 100644 --- a/class.templater.php +++ b/class.templater.php @@ -1092,10 +1092,11 @@ class TemplateInput extends TemplateStandaloneElement $this->parent = $parent; $type = "text"; - $value = ""; + $val = ""; $group = "general"; $name = null; $additional_list = array(); + $id = ""; $argument_list = implode(" ", $this->tokens); $argument_list = $this->ReplaceInlineVariables($argument_list, $data); @@ -1109,9 +1110,6 @@ class TemplateInput extends TemplateStandaloneElement case "name": $name = $argument[2]; break; - case "value": - $value = $argument[2]; - break; case "group": $group = $argument[2]; break; @@ -1122,7 +1120,10 @@ class TemplateInput extends TemplateStandaloneElement $type = $argument[2]; break; case "value": - $value = $argument[2]; + $val = $argument[2]; + break; + case "id": + $id = $argument[2]; break; default: $additional_list[$argument[1]] = $argument[2]; @@ -1137,9 +1138,14 @@ class TemplateInput extends TemplateStandaloneElement if(isset($_POST[$name])) { - $value = str_replace('"', '\"', htmlspecialchars($_POST[$name])); + $val = str_replace('"', '\"', htmlspecialchars($_POST[$name])); } - + + if(empty($id)) + { + $id = "form_{$group}_{$name}"; + } + $final_list = array(); foreach($additional_list as $key => $value) @@ -1149,7 +1155,7 @@ class TemplateInput extends TemplateStandaloneElement $additional = implode(" ", $final_list); - return ""; + return ""; } }