当前位置: 首页>>代码示例>>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;未经允许,请勿转载。