Commit 2157c0c2 authored by M Parker's avatar M Parker

The d3 sankey libraries accept 0 as a possible number of iterations.

parent 8f0ee093
......@@ -109,7 +109,7 @@ function d3_sankey_table_group_pp_field_formatter_settings_form($field, $instanc
$element['iterations'] = array(
'#type' => 'textfield',
'#title' => t('Iterations'),
'#element_validate' => array('element_validate_integer_positive'),
'#element_validate' => array('_d3_sankey_table_group_pp_element_validate_integer_positive_or_zero'),
'#default_value' => $settings['iterations'],
);
......@@ -343,3 +343,15 @@ function _d3_sankey_table_group_pp_default_chart_options() {
'type' => 'sankey',
);
}
/* Form callbacks. */
/**
* Form element validation handler for integers that must be positive or zero.
*/
function _d3_sankey_table_group_pp_element_validate_integer_positive_or_zero($element, &$form_state) {
$value = $element['#value'];
if ($value !== '' && (!is_numeric($value) || intval($value) != $value || $value < 0)) {
form_error($element, t('%name must be a positive integer or zero.', array('%name' => $element['#title'])));
}
}
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