function config_views_form_view_add_form_alter in Configuration Views 2.0.x
Same name and namespace in other branches
- 8 config_views.module \config_views_form_view_add_form_alter()
Implements hook_form_FORM_ID_alter().
File
- ./
config_views.module, line 13 - Contains Config Views implementation.
Code
function config_views_form_view_add_form_alter(&$form, FormStateInterface $form_state) {
$options = [];
foreach ($form['displays']['show']['wizard_key']['#options'] as $key => $option) {
$group = 'Content';
if (strpos($key, 'standard:') === 0 || strpos($key, 'config_views') === 0) {
$group = 'Configuration';
}
$options[$group][$key] = $option;
}
// Order by label, instead of key.
if (is_array($options['Content'])) {
uasort($options['Content'], function ($a, $b) {
return $a
->render() > $b
->render();
});
}
// Order by label, instead of key.
if (is_array($options['Content'])) {
uasort($options['Configuration'], function ($a, $b) {
return $a
->render() > $b
->render();
});
}
$form['displays']['show']['wizard_key']['#options'] = $options;
}