You are here

public function view_custom_table_handler_filter_date::validate_valid_time in Views Custom Table 7

Validate that the time values convert to something usable.

2 calls to view_custom_table_handler_filter_date::validate_valid_time()
view_custom_table_handler_filter_date::exposed_validate in views/handlers/view_custom_table_handler_filter_date.inc
Implements option_definition().
view_custom_table_handler_filter_date::options_validate in views/handlers/view_custom_table_handler_filter_date.inc
Implements option_definition().

File

views/handlers/view_custom_table_handler_filter_date.inc, line 87
Definition of views_handler_filter_date.

Class

view_custom_table_handler_filter_date
Filter to handle dates stored as a timestamp.

Code

public function validate_valid_time(&$form, $operator, $value) {
  $operators = $this
    ->operators();
  if ($operators[$operator]['values'] == 1) {
    $convert = strtotime($value['value']);
    if (!empty($form['value']) && ($convert == -1 || $convert === FALSE)) {
      form_error($form['value'], t('Invalid date format.'));
    }
  }
  elseif ($operators[$operator]['values'] == 2) {
    $min = strtotime($value['min']);
    if ($min == -1 || $min === FALSE) {
      form_error($form['min'], t('Invalid date format.'));
    }
    $max = strtotime($value['max']);
    if ($max == -1 || $max === FALSE) {
      form_error($form['max'], t('Invalid date format.'));
    }
  }
}