Commit 8e136a0b authored by merlinofchaos's avatar merlinofchaos

#108523: Properly validate that filter values need values selected.

parent fc30c0dd
......@@ -116,6 +116,7 @@ Views 4.7.x-dev
o #122103: Fix blank titles of blocks exported by views.
o #118069: Move the query cache into the real cache. This should clear up a few caching problems.
o #122818: Incorrect use of fullname when queryname should have been used
o #108523: Properly validate that filter values need values selected.
New features:
o #105620: (Attempt 2) allow modules to alter views tables + arguments
......
......@@ -103,7 +103,7 @@ function _views_get_tables($full = false) {
}
}
if ($data['list']) {
$data['value'] = array('#type' => 'select', '#options' => $data['list']);
$data['value'] = array('#type' => 'select', '#options' => $data['list'], '#validate' => array('views_filter_validate_array' => $data['name']));
if ($data['list-type'] != 'select') {
$data['value']['#multiple'] = TRUE;
}
......@@ -2055,6 +2055,22 @@ function views_handler_filter_timestamp($op, $filter, $filterinfo, &$query) {
$query->add_where("%s %s %s + %d", $field, $filter['operator'], $value, $filter['options']);
}
/**
* Provide validation for filters with array values. The $name
* must be provided by whatever added the validator to the
* form gadget.
*/
function views_filter_validate_array($form, $name) {
$op = $_POST['op'];
if ($op != t('Save')) {
return; // only validate on saving!
}
if (empty($form['#value'])) {
form_error($form, t('@filter must have a value!', array('@filter' => $name)));
}
}
/**
* Provide a form gadget for dates.
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment