Commit 4f010f5b authored by catch's avatar catch

Issue #1912466 by damiankloip, dawehner: Move array_filter_zero() function to FilterPluginBase.

parent fc750a42
......@@ -641,7 +641,7 @@ function build_group_validate($form, &$form_state) {
// Check if the title is defined but value wasn't defined.
if (!empty($group['title'])) {
if ((!is_array($group['value']) && trim($group['value']) == "") ||
(is_array($group['value']) && count(array_filter($group['value'], '_views_array_filter_zero')) == 0)) {
(is_array($group['value']) && count(array_filter($group['value'], 'static::arrayFilterZero')) == 0)) {
form_error($form['group_info']['group_items'][$id]['value'],
t('The value is required if title for this item is defined.'));
}
......@@ -649,7 +649,7 @@ function build_group_validate($form, &$form_state) {
// Check if the value is defined but title wasn't defined.
if ((!is_array($group['value']) && trim($group['value']) != "") ||
(is_array($group['value']) && count(array_filter($group['value'], '_views_array_filter_zero')) > 0)) {
(is_array($group['value']) && count(array_filter($group['value'], 'static::arrayFilterZero')) > 0)) {
if (empty($group['title'])) {
form_error($form['group_info']['group_items'][$id]['title'],
t('The title is required if value for this item is defined.'));
......@@ -1431,6 +1431,19 @@ function can_group() {
return TRUE;
}
/**
* Filter by no empty values, though allow to use "0".
*
* @param string $var
* The variable to evaluate.
*
* @return bool
* TRUE if the value is equal to an empty string, FALSE otherwise.
*/
protected static function arrayFilterZero($var) {
return trim($var) != '';
}
}
/**
......
......@@ -1768,15 +1768,6 @@ function _field_view_formatter_options($field_type = NULL) {
return $options;
}
/**
* Filter by no empty values, though allow to use "0".
* @param $var
* @return bool
*/
function _views_array_filter_zero($var) {
return trim($var) != "";
}
/**
* Adds one to each key of the array.
*
......
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