function form_styler_form_alter in jQuery form styler 8
Same name and namespace in other branches
- 7.2 form_styler.module \form_styler_form_alter()
- 7 form_styler.module \form_styler_form_alter()
File
- ./
form_styler.module, line 9 - Form styler module alters and hooks
Code
function form_styler_form_alter(array &$form, FormStateInterface $form_state, $form_id) {
$config = \Drupal::config('form_styler.settings');
$enabled_themes = $config
->get('themes_enabled');
$state = FALSE;
if (!empty($enabled_themes)) {
$theme = \Drupal::service('theme.manager')
->getActiveTheme();
$theme_name = $theme
->getName();
if (in_array($theme_name, array_filter($enabled_themes))) {
$state = TRUE;
}
}
$ids = explode(PHP_EOL, $config
->get('form_ids'));
$form_ids = array_map('trim', $ids);
if (in_array($form_id, $form_ids) && !$state) {
$state = TRUE;
}
if ($state) {
$form['#attached']['library'][] = 'form_styler/jquery-form-styler';
$form['#attributes']['class'][] = 'form-styler-ready';
}
}