Validate the options form.
Overrides PluginBase::validateOptionsForm
public function validateOptionsForm(&$form, &$form_state) {
switch ($form_state['section']) {
case 'display_title':
if (empty($form_state['values']['display_title'])) {
form_error($form['display_title'], t('Display title may not be empty.'));
}
break;
case 'css_class':
$css_class = $form_state['values']['css_class'];
if (preg_match('/[^a-zA-Z0-9-_ ]/', $css_class)) {
form_error($form['css_class'], t('CSS classes must be alphanumeric or dashes only.'));
}
break;
case 'display_id':
if ($form_state['values']['display_id']) {
if (preg_match('/[^a-z0-9_]/', $form_state['values']['display_id'])) {
form_error($form['display_id'], t('Display name must be letters, numbers, or underscores only.'));
}
foreach ($this->view->display as $id => $display) {
if ($id != $this->view->current_display && ($form_state['values']['display_id'] == $id || isset($display->new_id) && $form_state['values']['display_id'] == $display->new_id)) {
form_error($form['display_id'], t('Display id should be unique.'));
}
}
}
break;
case 'query':
if ($this->view->query) {
$this->view->query
->validateOptionsForm($form['query'], $form_state);
}
break;
}
// Validate plugin options. Every section with "_options" in it, belongs to
// a plugin type, like "style_options".
if (strpos($form_state['section'], '_options') !== FALSE) {
$plugin_type = str_replace('_options', '', $form_state['section']);
// Load the plugin and let it handle the validation.
if ($plugin = $this
->getPlugin($plugin_type)) {
$plugin
->validateOptionsForm($form[$form_state['section']], $form_state);
}
}
foreach ($this->extender as $extender) {
$extender
->validateOptionsForm($form, $form_state);
}
}