You are here

function type_style_attach_to_form in Type Style 8

Attaches Type Style elements to a form.

Parameters

array &$form: The form array.

array $settings: An array representing current type_style settings.

string $label: The label for the styled object.

3 calls to type_style_attach_to_form()
type_style_form_alter in ./type_style.module
Implements hook_form_alter().
type_style_moderation_form_workflow_state_edit_form_alter in modules/type_style_moderation/type_style_moderation.module
Implements hook_form_FORM_ID_alter().
type_style_moderation_form_workflow_transition_edit_form_alter in modules/type_style_moderation/type_style_moderation.module
Implements hook_form_FORM_ID_alter().

File

./type_style.module, line 49
Hook implementations for the Type Style module.

Code

function type_style_attach_to_form(&$form, $settings, $label) {
  $form['type_style'] = [
    '#type' => 'details',
    '#title' => t('Style settings'),
    '#tree' => TRUE,
  ];
  if (isset($form['additional_settings']) && $form['additional_settings']['#type'] === 'vertical_tabs') {
    $form['type_style']['#group'] = 'additional_settings';
  }
  $form['type_style']['color'] = [
    '#type' => 'color',
    '#title' => t('Color'),
    '#description' => t('A color to associate with this @label.', [
      '@label' => $label,
    ]),
    '#default_value' => isset($settings['color']) ? $settings['color'] : '',
  ];
  $form['type_style']['icon'] = [
    '#type' => 'textfield',
    '#title' => t('Icon name'),
    '#description' => t('An icon to associate with this @label.', [
      '@label' => $label,
    ]),
    '#default_value' => isset($settings['icon']) ? $settings['icon'] : '',
  ];
  $form['#validate'][] = 'type_style_form_validate';
}