public function html_type() {
# See: http://www.w3schools.com/html/html_form_input_types.asp
- if (strpos($this->name,'password') !== false) return 'password" autocomplete="off';
+ if (stripos($this->name,'password') !== false) return 'password" autocomplete="off';
if ($this->numeric() !== false) return 'number" step="any';
if ($this->autoincrement) return 'text" readonly="readonly';
return 'text';
# Html5 only
- if (strpos($this->name,'email') !== false) return 'email'; # no safari
+ if (stripos($this->name,'mail') !== false) return 'email'; # no safari
if (strpos($this->name,'color') !== false) return 'color'; # no safari, no ie
# NOT READY
if (strpos($this->type,'datetime') !== false) return 'datetime';
$html .= $this->htmlYesNo($value);
} else {
+ if ($tag == 'textarea' and $this->html_type() != 'text') $tag = 'input';
$html .= '<'.$tag
.' name="'.$this->preffix.$this->name.$suff.'"'
# NB 06.02.18 .' id="'.$this->name.'"'
# NB 06.02.18 $this->add_fields($fields);
# NB 06.02.18 }
+ public function replace_fields($fields) {
+ $this->fields = [];
+ return $this->add_fields($fields);
+ }
+
public function add_fields($fields) {
foreach ($fields as $k => $v) {
$key = false;
} else {
$fct = function() use($st) { if ($st->execute()) return $st->fetch(PDO::FETCH_ASSOC, PDO::FETCH_ORI_NEXT); };
}
- }
+
+ } # < nosql
+
+ # Check fields_only exists
+ if (!empty($this->fields_only)) foreach ($this->fields_only as $f) {
+ if (!$this->field($f)) $this->bye("Unknown field ".$f);
+ }
+
if (!empty($opt['query'])) return $st;
#
# Use the module out when format unknow
#'prepare' => function($sql) { return $this->ldap->prepare($sql); },
'rows_prepare' => function($table,$sql) {
$fields = (empty($table->fields_only) ? array_keys($table->fields()) : $table->fields_only);
+ $table->replace_fields($fields);
+ #debug(array_keys($table->fields()));
#foreach (array_keys($table->fields) as $k) { if (!in_array($k,$fields)) unset($table->fields[$k]); }
$table->db()->ldap->prepare($sql,['attrs'=>$fields]); return $table->db()->ldap;
},
$this->deniedUnless($this->perm >= self::READ);
$fields_only = (string)$args === '' ? [] : explode(',',$args);
- if (!empty($fields_only)) {
- foreach ($fields_only as $f) {
- if (!$this->table->field($f)) $this->error("Unknown field ".$f);
- }
- $this->table->fields_only = $fields_only;
- }
+ if (!empty($fields_only)) $this->table->fields_only = $fields_only;
$this->page($this,'table_rows');
}