function charts_plugin_style_chart::validate in Charts 7.2
Make sure the display and all associated handlers are valid.
Return value
Empty array if the display is valid; an array of error strings if it is not.
Overrides views_plugin_style::validate
File
- views/
charts_plugin_style_chart.inc, line 102 - Contains the Chart style (format) plugin (similar to Table, HTML List, etc.)
Class
- charts_plugin_style_chart
- Style plugin to render view as a chart.
Code
function validate() {
$errors = array();
$field_handlers = $this->display->handler
->get_handlers('field');
// Don't execute validation on the new view page.
if ($_GET['q'] === 'admin/structure/views/add') {
return;
}
// Make sure that all chart extensions first have a parent chart selected.
if ($this->plugin_name === 'chart_extension' && $this
->get_parent_chart_display() === FALSE) {
$errors[] = t('This chart add-on must have a parent chart selected under the chart settings.');
}
elseif (count($field_handlers)) {
$data_field_key = !empty($this->options['data_fields']) ? current($this->options['data_fields']) : NULL;
if (empty($data_field_key)) {
$errors[] = t('At least one data field must be selected in the chart configuration before this chart may be shown');
}
else {
$data_field = isset($field_handlers[$data_field_key]) ? $field_handlers[$data_field_key] : NULL;
if (!isset($data_field)) {
$errors[] = t('A field you have specified as a data field in your chart settings no longer exists. Edit the chart settings and select at least one data field.');
}
}
}
return $errors;
}