本文整理汇总了PHP中valid::date_mmddyyyy方法的典型用法代码示例。如果您正苦于以下问题:PHP valid::date_mmddyyyy方法的具体用法?PHP valid::date_mmddyyyy怎么用?PHP valid::date_mmddyyyy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类valid
的用法示例。
在下文中一共展示了valid::date_mmddyyyy方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validate_custom_form_fields
/**
* Validate Custom Form Fields
* @param Validation $post Validation object from form post
* XXX This whole function is being done backwards
* Need to pull the list of custom form fields first
* Then look through them to see if they're set, not the other way around.
*/
public static function validate_custom_form_fields(&$post)
{
$custom_fields = array();
if (!isset($post->custom_field)) {
return;
}
/* XXX Checkboxes hackery
Checkboxes are submitted in the post as custom_field[field_id-boxnum]
This foreach loop consolidates them into one variable separated by commas.
If no checkboxes are selected then the custom_field[] for that variable is not sent
To get around that the view sets a hidden custom_field[field_id-BLANKHACK] field that
ensures the checkbox custom_field is there to be tested.
*/
foreach ($post->custom_field as $field_id => $field_response) {
$split = explode("-", $field_id);
if (isset($split[1])) {
// The view sets a hidden field for blankhack
if ($split[1] == 'BLANKHACK') {
if (!isset($custom_fields[$split[0]])) {
// then no checkboxes were checked
$custom_fields[$split[0]] = '';
}
// E.Kala - Removed the else {} block; either way continue is still invoked
continue;
}
if (isset($custom_fields[$split[0]])) {
$custom_fields[$split[0]] .= ",{$field_response}";
} else {
$custom_fields[$split[0]] = $field_response;
}
} else {
$custom_fields[$split[0]] = $field_response;
}
}
$post->custom_field = $custom_fields;
// Kohana::log('debug', Kohana::debug($custom_fields));
foreach ($post->custom_field as $field_id => $field_response) {
$field_param = ORM::factory('form_field', $field_id);
$custom_name = $field_param->field_name;
// Validate that this custom field already exists
if (!$field_param->loaded) {
// Populate the error field
//$errors[$field_id] = "The $custom_name field does not exist";
$post->add_error('custom_field', 'not_exist', array($field_id));
return;
}
$max_auth = self::get_user_max_auth();
$required_role = ORM::factory('role', $field_param->field_ispublic_submit);
if (($required_role->loaded ? $required_role->access_level : 0) > $max_auth) {
// Populate the error field
$post->add_error('custom_field', 'permission', array($custom_name));
return;
}
// Validate that the field is required
if ($field_param->field_required == 1 and $field_response == "") {
$post->add_error('custom_field', 'required', array($custom_name));
return;
}
// Grab the custom field options for this field
$field_options = self::get_custom_field_options($field_id);
// Validate Custom fields for text boxes
if ($field_param->field_type == 1 and isset($field_options) and $field_response != '') {
if (isset($field_options['field_datatype'])) {
if ($field_options['field_datatype'] == 'email' and !valid::email($field_response)) {
$post->add_error('custom_field', 'email', array($custom_name));
}
if ($field_options['field_datatype'] == 'phonenumber' and !valid::phone($field_response)) {
$post->add_error('custom_field', 'phone', array($custom_name));
}
if ($field_options['field_datatype'] == 'numeric' and !valid::numeric($field_response)) {
$post->add_error('custom_field', 'numeric', array($custom_name));
}
}
}
// Validate for date
if ($field_param->field_type == 3 and $field_response != "") {
$field_default = $field_param->field_default;
if (!valid::date_mmddyyyy($field_response)) {
$post->add_error('custom_field', 'date_mmddyyyy', array($custom_name));
}
}
// Validate multi-value boxes only have acceptable values
if ($field_param->field_type >= 5 and $field_param->field_type <= 7) {
$defaults = explode('::', $field_param->field_default);
$options = array();
if (preg_match("/[0-9]+-[0-9]+/", $defaults[0]) and count($defaults) == 1) {
$dashsplit = explode('-', $defaults[0]);
$start = $dashsplit[0];
$end = $dashsplit[1];
for ($i = $start; $i <= $end; $i++) {
array_push($options, $i);
}
} else {
//.........这里部分代码省略.........