本文整理汇总了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();
}