form_styler.module in jQuery form styler 8
Same filename and directory in other branches
Form styler module alters and hooks
File
form_styler.moduleView source
<?php
/**
* @file
* Form styler module alters and hooks
*/
use Drupal\Core\Form\FormStateInterface;
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';
}
}
Functions
Name | Description |
---|---|
form_styler_form_alter |