You are here

function hook_type_style_form_alter in Type Style 8

Alter the form used by Type Style to configure styles.

Note: If you're adding a new style, you'll also need to define its schema. See config/schema/type_style.schema.yml for reference.

Parameters

array &$form: The full type form. Add new styles to $form['type_style'].

\Drupal\Core\Config\Entity\ConfigEntityBundleBase $type: The type being edited.

1 invocation of hook_type_style_form_alter()
type_style_form_alter in ./type_style.module
Implements hook_form_alter().

File

./type_style.api.php, line 24
Hooks related to Type Style module.

Code

function hook_type_style_form_alter(array &$form, \Drupal\Core\Config\Entity\ConfigEntityBundleBase $type) {
  $label = $type
    ->getEntityType()
    ->getLabel();
  $settings = $type
    ->getThirdPartySettings('type_style');
  $form['type_style']['secondary_color'] = [
    '#type' => 'color',
    '#title' => t('Secondary color'),
    '#description' => t('The secondary color for this @label', [
      '@label' => $label,
    ]),
    '#default_value' => isset($settings['secondary_color']) ? $settings['secondary_color'] : '',
  ];

  /* @see type_style_entity_builder() for reference on how to set values. */
  $form['#entity_builders'][] = 'your_module_type_style_entity_builder';
}