function claro_form_alter in Drupal 8
Same name and namespace in other branches
- 9 core/themes/claro/claro.theme \claro_form_alter()
- 10 core/themes/claro/claro.theme \claro_form_alter()
Implements hook_form_alter().
File
- core/
themes/ claro/ claro.theme, line 362 - Functions to support theming in the Claro theme.
Code
function claro_form_alter(array &$form, FormStateInterface $form_state, $form_id) {
$build_info = $form_state
->getBuildInfo();
$form_object = $form_state
->getFormObject();
// Make entity forms delete link use the action-link component.
if (isset($form['actions']['delete']['#type']) && $form['actions']['delete']['#type'] === 'link' && !empty($build_info['callback_object']) && $build_info['callback_object'] instanceof EntityForm) {
$form['actions']['delete'] = _claro_convert_link_to_action_link($form['actions']['delete'], 'trash', 'default', 'danger');
}
if ($form_object instanceof ViewsForm && strpos($form_object
->getBaseFormId(), 'views_form_media_library') === 0) {
if (isset($form['header'])) {
$form['header']['#attributes']['class'][] = 'media-library-views-form__header';
$form['header']['media_bulk_form']['#attributes']['class'][] = 'media-library-views-form__bulk_form';
}
$form['actions']['submit']['#attributes']['class'] = [
'media-library-select',
];
}
}