Loading field_label.module +21 −5 Original line number Diff line number Diff line Loading @@ -5,10 +5,11 @@ * Provides custom settings to format field labels. */ use Drupal\Component\Utility\Html; use Drupal\Core\Field\FormatterInterface; use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Form\FormStateInterface; use Drupal\Component\Utility\Html; use Drupal\Core\Routing\RouteMatchInterface; /** * Implements hook_theme_registry_alter(). Loading Loading @@ -141,7 +142,8 @@ function field_label_field_formatter_third_party_settings_form(FormatterInterfac '#title' => t('Label class'), '#description' => t('Select a class to add to the label tag.'), '#empty_value' => '', '#options' => _field_label_generate_styles(), // '#options' => _field_label_generate_styles(), '#options' => _field_label_build_options(), '#default_value' => $default, ]; } Loading Loading @@ -251,7 +253,7 @@ function field_label_preprocess_field(&$variables) { /** * Implements hook_help(). */ function field_label_help($route_name, \Drupal\Core\Routing\RouteMatchInterface $route_match) { function field_label_help($route_name, RouteMatchInterface $route_match) { switch ($route_name) { case 'help.page.field_label': $text = file_get_contents(__DIR__ . '/README.md'); Loading @@ -270,7 +272,6 @@ function field_label_help($route_name, \Drupal\Core\Routing\RouteMatchInterface return ''; } /** * Ensure a style selector is still available in the configured class list. * Loading @@ -291,11 +292,26 @@ function _field_label_is_valid_style($selector) { return []; } /** * Create an array of classes suitable for use as Form API options. * * @return array * An array of classes with associated translatable/filtered label values. */ function _field_label_build_options() { $styles = _field_label_generate_styles(); $options = []; foreach ($styles as $class => $label) { $options[$class] = t('@label', ['@label' => $label]); } return $options; } /** * Create an array of validated key/value pairs of class selector and labels. * * @return array * An array with valid values, or empty values if selector is not valid * An array with valid values. */ function _field_label_generate_styles() { $class_list = \Drupal::config('field_label.settings')->get('class_list'); Loading Loading
field_label.module +21 −5 Original line number Diff line number Diff line Loading @@ -5,10 +5,11 @@ * Provides custom settings to format field labels. */ use Drupal\Component\Utility\Html; use Drupal\Core\Field\FormatterInterface; use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Form\FormStateInterface; use Drupal\Component\Utility\Html; use Drupal\Core\Routing\RouteMatchInterface; /** * Implements hook_theme_registry_alter(). Loading Loading @@ -141,7 +142,8 @@ function field_label_field_formatter_third_party_settings_form(FormatterInterfac '#title' => t('Label class'), '#description' => t('Select a class to add to the label tag.'), '#empty_value' => '', '#options' => _field_label_generate_styles(), // '#options' => _field_label_generate_styles(), '#options' => _field_label_build_options(), '#default_value' => $default, ]; } Loading Loading @@ -251,7 +253,7 @@ function field_label_preprocess_field(&$variables) { /** * Implements hook_help(). */ function field_label_help($route_name, \Drupal\Core\Routing\RouteMatchInterface $route_match) { function field_label_help($route_name, RouteMatchInterface $route_match) { switch ($route_name) { case 'help.page.field_label': $text = file_get_contents(__DIR__ . '/README.md'); Loading @@ -270,7 +272,6 @@ function field_label_help($route_name, \Drupal\Core\Routing\RouteMatchInterface return ''; } /** * Ensure a style selector is still available in the configured class list. * Loading @@ -291,11 +292,26 @@ function _field_label_is_valid_style($selector) { return []; } /** * Create an array of classes suitable for use as Form API options. * * @return array * An array of classes with associated translatable/filtered label values. */ function _field_label_build_options() { $styles = _field_label_generate_styles(); $options = []; foreach ($styles as $class => $label) { $options[$class] = t('@label', ['@label' => $label]); } return $options; } /** * Create an array of validated key/value pairs of class selector and labels. * * @return array * An array with valid values, or empty values if selector is not valid * An array with valid values. */ function _field_label_generate_styles() { $class_list = \Drupal::config('field_label.settings')->get('class_list'); Loading