You are here

function webform_bootstrap_test_module_webform_element_alter in Webform 8.5

Same name and namespace in other branches
  1. 6.x modules/webform_bootstrap/tests/modules/webform_bootstrap_test_module/webform_bootstrap_test_module.inc \webform_bootstrap_test_module_webform_element_alter()

Implements hook_webform_element_alter().

File

modules/webform_bootstrap/tests/modules/webform_bootstrap_test_module/webform_bootstrap_test_module.inc, line 29
Alter hooks to increase webform input and button size.

Code

function webform_bootstrap_test_module_webform_element_alter(array &$element, FormStateInterface $form_state, array $context) {
  if (!isset($element['#type'])) {
    return;
  }

  // Add 'input-lg' to elements generate input's that support #attribute.
  switch ($element['#type']) {
    case 'webform_checkboxes_other':
    case 'webform_radios_other':
    case 'webform_buttons_other':
      $element['#other__attributes']['class'][] = 'input-lg';
      break;
    case 'webform_select_other':
      $element['#attributes']['class'][] = 'input-lg';
      $element['#other__attributes']['class'][] = 'input-lg';
      break;
    case 'textfield':
    case 'textarea':
    case 'email':
    case 'entity_autocomplete':
    case 'password':
    case 'select':
    case 'date':
    case 'datelist':
    case 'tel':
    case 'url':
    case 'webform_autocomplete':
    case 'webform_email_multiple':
    case 'webform_time':
    case 'webform_term_select':
    case 'webform_entity_select':
      $element['#attributes']['class'][] = 'input-lg';
      break;
  }
}