當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Form_Input::validate方法代碼示例

本文整理匯總了PHP中Form_Input::validate方法的典型用法代碼示例。如果您正苦於以下問題:PHP Form_Input::validate方法的具體用法?PHP Form_Input::validate怎麽用?PHP Form_Input::validate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Form_Input的用法示例。


在下文中一共展示了Form_Input::validate方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: validate

 public function validate()
 {
     // The upload directory must always be set
     empty($this->directory) and $this->directory();
     // By default, there is no uploaded file
     $filename = '';
     if ($status = parent::validate() and $this->upload['error'] === UPLOAD_ERR_OK) {
         // Set the filename to the original name
         $filename = $this->upload['name'];
         if (Kohana::config('upload.remove_spaces')) {
             // Remove spaces, due to global upload configuration
             $filename = preg_replace('/\\s+/', '_', $this->data['value']);
         }
         if (file_exists($filepath = $this->directory . $filename)) {
             if ($this->filename !== TRUE or !is_writable($filepath)) {
                 // Prefix the file so that the filename is unique
                 $filepath = $this->directory . 'uploadfile-' . uniqid(time()) . '-' . $this->upload['name'];
             }
         }
         // Move the uploaded file to the upload directory
         move_uploaded_file($this->upload['tmp_name'], $filepath);
     }
     if (!empty($_POST[$this->data['name']])) {
         // Reset the POST value to the new filename
         $this->data['value'] = $_POST[$this->data['name']] = empty($filepath) ? '' : $filepath;
     }
     return $status;
 }
開發者ID:xafr,項目名稱:gallery3,代碼行數:28,代碼來源:Form_Upload.php

示例2: validate

 public function validate()
 {
     // Validation has already run
     if (is_bool($this->is_valid)) {
         return $this->is_valid;
     }
     if ($this->input_value() == FALSE) {
         // No data to validate
         return $this->is_valid = FALSE;
     }
     // Load the submitted value
     $this->load_value();
     if (!array_key_exists($this->value, $this->data['options'])) {
         // Value does not exist in the options
         return $this->is_valid = FALSE;
     }
     return parent::validate();
 }
開發者ID:TODDMAN,項目名稱:gallery3-vendor,代碼行數:18,代碼來源:Form_Dropdown.php


注:本文中的Form_Input::validate方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。