]> git.nbdom.net Git - nb.git/commitdiff
lib/php/db/field.php
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Sun, 18 Feb 2018 21:58:56 +0000 (21:58 +0000)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Sun, 18 Feb 2018 21:58:56 +0000 (21:58 +0000)
lib/php/db/field.php

index 5772fa78852a8f279c4828f4509a44cf55b61d01..7ea29a5a9adb9e8c2c1f0ec911dd2183c4be4270 100644 (file)
@@ -122,7 +122,9 @@ class field extends nb {
                if ($type === null) $type = $this->html_type();
 
                foreach ($values as $value) {
-       $html .= '<div class="label '.$this->name.'"><label for="'.$this->name.'">'.htmlspecialchars(prettyText($this->name)).'</label>';
+       $html .= '<div class="label '.$this->name.'">'
+                               .'<label for="'.$this->name.'">'.htmlspecialchars(prettyText($this->name)).'</label>'
+                       ;
 
        if ($this->extras) {
        $html .= '<span class="extra '.$this->name.'">'.$this->out($value).'</span>';
@@ -131,6 +133,7 @@ class field extends nb {
        $html .= $this->htmlYesNo($value);
 
        } else {
+                               # NB 09.02.18: needed ? 
                                if ($tag == 'textarea' and $type != 'text') $tag = 'input';
                                if ($media = Mime::html($value,'')) {
                                        $tag = 'input';
@@ -138,18 +141,17 @@ class field extends nb {
                                        $html .= $media;
                                }
 
-                               # NB 09.02.18: needed ? 
-                               #$tag = 'textarea';
        $html .= '<'.$tag
                .' name="'.$this->preffix.$this->name.$suff.'"'
-       # NB 06.02.18         .' id="'.$this->name.'"'
                .( ($size and $tag != 'textarea') ? ' size="'.$size.'"' : '')
-               #.' value="'.$value.'"'
                .($tag == 'textarea' ? '>'.$value.'</textarea>' : ' type="'.$type.'" value="'.htmlspecialchars($value).'" />')
        ;
 
        }
 
+                       # If more than one value, add js code to add more values
+                       if ($suff) $html .= '<a href="#" onclick="var i=this.parentNode;var j=i.cloneNode(true);j.querySelectorAll(\'input, textarea, select\').forEach(function(e) {e.value=\'\';}); i.parentNode.insertBefore(j, i.nextSibling);console.log(i.className); return false;">+</a>';
+
        $html .= '</div>'.NB_EOL;
                }