How to theme input element?

function mytheme_preprocess_input(&$variables) {
  }
  function mytheme_preprocess_form_element(&$variables) {
  }
  function mytheme_preprocess_form_element_label(&$variables) {
  }

  We need to customize the rendering of form_element. I implemented hook_theme_suggestions_form_element_alter to “suggest” using a different template when we want a wrapped label.

  function mytheme_theme_suggestions_form_element_alter(array &$suggestions, array $variables) {
    if (!empty($variables['element']['#wrapped_label'])) {
      $suggestions[] = 'form_element__wrap';
    }
  }

  Now we can implement a preprocess function for this template.

  function mytheme_preprocess_form_element__wrap(&$variables) {
    $variables['label']['#theme'] = 'form_element_label__open';
    $variables['label_open'] = $variables['label'];
    unset($variables['label']);
    $variables['title'] = $variables['element']['#title'];
  }

Tags

Instagram Without API

Could not reach Instagram server