From 56b619b7775ef0afe4442aa504f7a69a9e05664a Mon Sep 17 00:00:00 2001 From: "Roman Schmerold (BNoiZe)" Date: Thu, 5 Feb 2015 09:40:23 +0100 Subject: [PATCH] Update generation of unlimited fields Signed-off-by: Roman Schmerold (BNoiZe) --- lib/classes/output/class.HTMLform2.php | 27 +++++++++++++------------- templates/Sparkle/htmlform/inputul.tpl | 1 + templates/Sparkle/htmlform/textul.tpl | 1 - 3 files changed, 15 insertions(+), 14 deletions(-) create mode 100644 templates/Sparkle/htmlform/inputul.tpl delete mode 100644 templates/Sparkle/htmlform/textul.tpl diff --git a/lib/classes/output/class.HTMLform2.php b/lib/classes/output/class.HTMLform2.php index 4c755710..357ac131 100644 --- a/lib/classes/output/class.HTMLform2.php +++ b/lib/classes/output/class.HTMLform2.php @@ -29,7 +29,7 @@ class HTMLform2 { * @param array $data (default: array()) * @return void */ - public static function genHTMLform($formdata = array(), $data = array()) { + public static function genHTMLform($formdata = array(), $data = false) { global $lng, $theme; self::$_form = ''; @@ -47,9 +47,9 @@ class HTMLform2 { if (isset($fielddata['visible'])) { if ($fielddata['visible'] == false) { continue; - } elseif ($fielddata['visible'] === 'new' && !empty($data)) { + } elseif ($fielddata['visible'] === 'new' && is_array($data)) { continue; - } elseif ($fielddata['visible'] === 'edit' && empty($data)) { + } elseif ($fielddata['visible'] === 'edit' && !is_array($data)) { continue; } } @@ -263,25 +263,26 @@ class HTMLform2 { global $lng; // Input - $inputdata = $fielddata; - $inputdata['value'] = ($inputdata['value'] == -1) ? '' : $inputdata['value']; - $inputdata['type'] = "text"; - $input = self::_input($fieldname, $inputdata); - + $attributes_input = self::_parseAttributes($fieldname, $fielddata); + $attributes_input['type'] = "text"; + $attributes_input['value'] = ($fielddata['value'] == '-1') ? '' : $fielddata['value']; + $attributes_input = self::_glueAttributes($attributes_input); + // Checkbox $checkboxdata = array( - //'label' => $lng['admin']['stdsubdomain_add'].'?', - 'type' => 'checkbox', 'label' => $lng['customer']['unlimited'], + 'type' => 'checkbox', 'value' => '-1', 'attributes' => array( 'checked' => ($fielddata['value'] == '-1') ? true : false ) ); + $attributes_checkbox = self::_parseAttributes($fieldname . "_ul", $checkboxdata); + $attributes_checkbox['type'] = $checkboxdata['type']; + $attributes_checkbox = self::_glueAttributes($attributes_checkbox); + $label_checkbox = $checkboxdata['label']; - $checkbox = self::_inputCheckbox($fieldname . "_ul", $checkboxdata, false); - - eval("\$return = \"" . getTemplate("htmlform/textul", "1") . "\";"); + eval("\$return = \"" . getTemplate("htmlform/inputul", "1") . "\";"); return $return; } diff --git a/templates/Sparkle/htmlform/inputul.tpl b/templates/Sparkle/htmlform/inputul.tpl new file mode 100644 index 00000000..89b8130a --- /dev/null +++ b/templates/Sparkle/htmlform/inputul.tpl @@ -0,0 +1 @@ +  diff --git a/templates/Sparkle/htmlform/textul.tpl b/templates/Sparkle/htmlform/textul.tpl deleted file mode 100644 index b8909fa3..00000000 --- a/templates/Sparkle/htmlform/textul.tpl +++ /dev/null @@ -1 +0,0 @@ -{$input} {$checkbox}