From: Nicolas Boisselier Date: Sun, 18 Feb 2018 22:13:12 +0000 (+0000) Subject: lib/php/db/field.php X-Git-Url: https://git.nbdom.net/?a=commitdiff_plain;h=5ead5844fe5e2ebc310058846acb413f3e00af87;p=nb.git lib/php/db/field.php --- diff --git a/lib/php/db/field.php b/lib/php/db/field.php index 7ea29a5a..9e8bbfc3 100644 --- a/lib/php/db/field.php +++ b/lib/php/db/field.php @@ -117,11 +117,11 @@ class field extends nb { $html = ''; - $values = (array)$values; - $suff = count( $values ) > 1 ? '[]' : ''; + $multi = is_array($values) ? true : false; + $suff = $multi ? '[]' : ''; if ($type === null) $type = $this->html_type(); - foreach ($values as $value) { + foreach ((array)$values as $value) { $html .= '
' .'' ; @@ -142,7 +142,7 @@ class field extends nb { } $html .= '<'.$tag - .' name="'.$this->preffix.$this->name.$suff.'"' + .' name="'.$this->preffix.$this->name . ($multi ? '[]' : '') . '"' .( ($size and $tag != 'textarea') ? ' size="'.$size.'"' : '') .($tag == 'textarea' ? '>'.$value.'' : ' type="'.$type.'" value="'.htmlspecialchars($value).'" />') ; @@ -150,7 +150,7 @@ class field extends nb { } # If more than one value, add js code to add more values - if ($suff) $html .= '+'; + if ($multi) $html .= '+'; $html .= '
'.NB_EOL; }