Etable/formType/file:修訂版本之間的差異
出自六年制學程
(→addElements($i,$value)) |
(→製作表單元素類別) |
||
第 1 行: | 第 1 行: | ||
[[分類:Etable]] | [[分類:Etable]] | ||
− | ===製作表單元素類別=== | + | ====(一)製作表單元素類別==== |
+ | formsome.php 中 | ||
+ | <pre>class XoopsFormUploadFile extends XoopsFormElement { | ||
+ | function XoopsFormUploadFile($caption, $name){ // 提示、後傳變數名 | ||
+ | $this->setCaption($caption); | ||
+ | $this->setName($name); | ||
+ | } | ||
+ | function render(){ | ||
+ | return "<input type='file' name='".$this->getName()."' id='".$this->getName()."'".$this->getExtra()." />".$this->getExtra('2'); | ||
+ | } | ||
+ | } | ||
+ | class XoopsFormFile extends XoopsFormElementTray{ | ||
+ | function XoopsFormFile($caption, $name, $value='', $paths=array('.'=>'當前路徑')){ | ||
+ | $this->XoopsFormElementTray($caption,' '); | ||
+ | $pathSelect=new XoopsFormSelect('路徑:',$name.'[path]',$value='');// 產生選單物件並指定預選值 | ||
+ | $pathSelect->addOptionArray($paths); | ||
+ | $this->addElement($pathSelect);// 將選單物件放入表單 | ||
+ | $fileUpload=new XoopsFormUploadFile('請選檔:', $name.'[fileName]'); | ||
+ | $this->addElement($fileUpload);// 將選單物件放入表單 | ||
+ | } | ||
+ | }</pre> | ||
===addElements($i,$value)=== | ===addElements($i,$value)=== |
2022年7月6日 (三) 11:31的修訂版本
目錄
(一)製作表單元素類別
formsome.php 中
class XoopsFormUploadFile extends XoopsFormElement { function XoopsFormUploadFile($caption, $name){ // 提示、後傳變數名 $this->setCaption($caption); $this->setName($name); } function render(){ return "<input type='file' name='".$this->getName()."' id='".$this->getName()."'".$this->getExtra()." />".$this->getExtra('2'); } } class XoopsFormFile extends XoopsFormElementTray{ function XoopsFormFile($caption, $name, $value='', $paths=array('.'=>'當前路徑')){ $this->XoopsFormElementTray($caption,' '); $pathSelect=new XoopsFormSelect('路徑:',$name.'[path]',$value='');// 產生選單物件並指定預選值 $pathSelect->addOptionArray($paths); $this->addElement($pathSelect);// 將選單物件放入表單 $fileUpload=new XoopsFormUploadFile('請選檔:', $name.'[fileName]'); $this->addElement($fileUpload);// 將選單物件放入表單 } }
addElements($i,$value)
加表單元素類型為 file 則$j=new XoopsFormFile($this->fields[$i]['colalias'],'f['.$this->fields[$i]['as_name'].']['.$this->fields[$i]['colname'].']',str_replace("'",''',str_replace("&",'&',$value)),$this->formType["$lc_name"][1]['paths']); $this->form->addElement($j,(($this->fields[$i]['formValidate']==0)?'0':'1'));