update 2023-08-04 fixed cache, form and fonia3.js
This commit is contained in:
+17
-6
@@ -6,7 +6,7 @@
|
||||
Desc. : v3 - Form Generator (jQuery & Bootstrap)
|
||||
Created By : Siau Pheng ([email protected]).
|
||||
Created Date : February 27th, 2008.
|
||||
Last Modified : March 24th, 2023.
|
||||
Last Modified : July 5th, 2023.
|
||||
|
||||
(c) 2008 - 2023, 3FONIA Software; WWW.3FONIA.COM.
|
||||
|
||||
@@ -29,25 +29,36 @@ final class Form {
|
||||
$this->__button = new Button();
|
||||
}
|
||||
|
||||
public function option($tlabel="", $tfield, $tvalue=null, $benable=true, $breq=false, $aarr=array(), $thelp="", $tchange=null, $bmulti=false) {
|
||||
public function option($tlabel="", $tfield, $tvalue=null, $benable=true, $breq=false, $aarr=array(), $thelp="", $tchange=null, $bmulti=false, $bgroup=false) {
|
||||
$_enab = ($benable==true) ? "" : ' disabled=true';
|
||||
$_req = ($breq==true) ? " required=true" : "";
|
||||
$_change = ($tchange==null) ? '' : ' onchange="'.$tchange.'"';
|
||||
$_multi = ($bmulti==true) ? ' multiple' : '';
|
||||
$tout = '<select class="form-select option-tags" id="'.$tfield.'" name="'.$tfield.'"'.$_enab.$_change.$_req.$_multi.' >';
|
||||
if (count($aarr)>0) {
|
||||
$n_group = 0;
|
||||
foreach ($aarr as $key => $val) {
|
||||
$_val2 = $val; $olabel = "";
|
||||
if (is_array($val)) {
|
||||
$_val2 = $val[0];
|
||||
$olabel = (isset($val[1])) ? ' olabel="'.$val[1].'"' : "";
|
||||
if ($bgroup) {
|
||||
if (1==$val[1]) {
|
||||
if (0<$n_group++) $tout .= '</optgroup>';
|
||||
$tout .= '<optgroup label="'.$_val2.'">';
|
||||
//$n_group++;
|
||||
}
|
||||
} else {
|
||||
$olabel = (isset($val[1])) ? ' olabel="'.$val[1].'"' : "";
|
||||
}
|
||||
}
|
||||
if ($bgroup && $val[1]==1) continue;
|
||||
$tout .= '<option value="'.$key.'"'.$olabel;
|
||||
$aval = array($tvalue);
|
||||
if ($bmulti==true) $aval = explode(",", ($tvalue ?? "0"));
|
||||
$tout .= (in_array($key, $aval)) ? ' selected="selected"' : "";
|
||||
$tout .= '>'.$_val2.'</option>';
|
||||
}
|
||||
if ($bgroup && $n_group>0) $tout .= '</optgroup>';
|
||||
}
|
||||
$tout .= '</select>';
|
||||
$this->__aform[$tfield] = array('label'=>$tlabel, 'help'=>$thelp, 'form'=>$tout);
|
||||
@@ -58,12 +69,12 @@ final class Form {
|
||||
$afield = ($afield==null) ? array("ID", "Nama", "Label") : $afield;
|
||||
$_twhere = ($twhere==null) ? "" : " WHERE ".$twhere;
|
||||
$_twhere .= ($twhere===null || stripos($twhere,"ORDER BY")===false) ? " ORDER BY ".$afield[1] : "";
|
||||
$ahasil = array();
|
||||
if (is_array($addarray)) $ahasil[$addarray[0]] = (!isset($afield[2])) ? $addarray[1] : array($addarray[1], $addarray[2]);
|
||||
$ahasil = [];
|
||||
if (is_array($addarray)) $ahasil[$addarray[0]] = (!isset($afield[2])) ? $addarray[1] : [$addarray[1], $addarray[2]];
|
||||
if ($ttable<>null) {
|
||||
$this->__db->Query("SELECT ".implode(",", $afield)." FROM ".$ttable.$_twhere);
|
||||
while ($this->__db->Next()) {
|
||||
$ahasil[$this->__db->Row($afield[0])] = (!isset($afield[2])) ? $this->__db->Row($afield[1]) : array($this->__db->Row($afield[1]), $this->__db->Row($afield[2]));
|
||||
$ahasil[$this->__db->Row($afield[0])] = (!isset($afield[2])) ? $this->__db->Row($afield[1]) : [$this->__db->Row($afield[1]), $this->__db->Row($afield[2])];
|
||||
}
|
||||
}
|
||||
$tout = $this->option($tlabel, $tfield, $tvalue, $benable, $breq, $ahasil, $thelp, $tchange, $bmulti);
|
||||
|
||||
Reference in New Issue
Block a user