]> git.nbdom.net Git - nb.git/commitdiff
lib/php/db/field.php htmlYesNo
authorDevops <sys@15gifts.com>
Sat, 13 May 2017 15:31:56 +0000 (16:31 +0100)
committerDevops <sys@15gifts.com>
Sat, 13 May 2017 15:31:56 +0000 (16:31 +0100)
lib/php/db/field.php
www/dbq/html/default.css

index d3295869183c2acb1fcfe2b58915426f4fd9ecb7..7da5cb6bee69cd10567d18f79398ce03c775c3c6 100644 (file)
@@ -73,6 +73,19 @@ class field extends nb {
     if (strpos($this->type,'date') !== false) return 'date';
   }
 
+  public function htmlYesNo($checked_value) {
+
+    $s_no = $checked = ' checked="checked"';
+    if ( ( $s_yes = preg_match('/^(1|yes|on|true)/i',$checked_value) ? $checked : '' ) != '' ) $s_no = '';
+
+    $t1 = 'span'; $t2 = "</$t1>"; $t1 = "<$t1>";
+    return $t1
+      .'Yes <input type="radio" name="'.$this->name.'" value="1"'.$s_yes.'>'
+      .'No <input type="radio" name="'.$this->name.'" value="0"'.$s_no.'>'
+    .$t2;
+
+  }
+
   public function html_edit($value,$type=null) {
 
     $size = ($this->size() and is_scalar($this->size())) ? $this->size() : 0;
@@ -82,9 +95,8 @@ class field extends nb {
     if ($this->extras) {
       $html = '<span class="extra" id="'.$this->name.'">'.$this->out($value).'</span>';
 
-    } elseif (strpos($this->type,'Zbool') !== false) {
-      $html .= '<span>Yes</span><input type="checkbox" name="'.$this->name.'" value="1">';
-      $html .= '<span>No</span><input type="checkbox" name="'.$this->name.'" value="0">';
+    } elseif (strpos($this->type,'bool') !== false) {
+      $html .= $this->htmlYesNo($value);
 
     } else {
       $html = '<'.$tag
index 539fddc87fcea8732c14a98273559a78ebc25251..64fd5d2e3cf6345f79339a26d5365374e9e7fef6 100644 (file)
@@ -82,7 +82,7 @@ form label:after { content: ':'; }
 form label,
 form input,
 form select {
-  vertical-align: middle;
+  vertical-align: top;
   margin: 0.2em 0.4em 0.2em 0;
 }
 
@@ -237,29 +237,12 @@ form.menu .criterias span.label:last-child {
   border-right: none;
 }
 
-form.menu select:focus {
-  max-width: auto;
-}
-form.menu select {
-  max-width: 20%;
-}
+form.menu select:focus { max-width: auto; }
 
-form.menu .criterias input[type=text]:focus {
-  width: auto;
-}
-form.menu .criterias input[type=text] {
-  width: 4em;
-}
-/*
-form.menu .criterias label {
-  width: 60%;
-  display: inline-block;
-}
-form.menu .criterias input {
-  width: 30%;
-  display: inline-block;
-}
-*/
+form.menu select { max-width: 20%; }
+
+form.menu .criterias input[type=text]:focus { width: auto; }
+form.menu .criterias input[type=text] { width: 4em; }
 
 /*
 EDIT PAGE
@@ -271,30 +254,26 @@ form.edit .fields label {
   margin-right: 1em;
   vertical-align: top;
 }
+
 form.edit .fields .label span {
   width: 54%;
   display: inline-block;
   text-align: left;
+  vertical-align: middle;
 }
 
-form.edit .fields input, form.edit .fields textarea, form.edit .fields select {
+/*
+input[type='text'],
+input[type='password'],
+input[type='date'],
+input[type='email'],
+input[type='url'],
+input[type='']
+*/
+form.edit .fields input[size],
+form.edit .fields textarea, form.edit .fields select {
   width: 65%;
 }
-
-form.edit .fields label {
-  width: 25%;
-  text-align: right;
-  display: inline-block;
-  margin-right: 1em;
-  vertical-align: top;
-}
-
-form.edit .fields .label span {
-  width: 54%;
-  display: inline-block;
-  text-align: left;
-}
-
 /*
 form.edit input[type=checkbox] {
   text-align: left;