本文整理匯總了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;
}
示例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();
}