Commit 6bab8b92 authored by Andrii Chyrskyi's avatar Andrii Chyrskyi
Browse files

Merge pull request #2460 from goalgorilla/feature/3179171-add-autocomplete-profile-edit-fields

Issue #3179171 by agami4: Add autocomplete attr to the profile edit fields
parent 84d6c341
Loading
Loading
Loading
Loading
+22 −0
Original line number Diff line number Diff line
@@ -46,13 +46,35 @@ function social_profile_field_widget_form_alter(&$element, FormStateInterface $f
    case 'field_profile_phone_number':
      // @todo Remove this when rule for .form-tel elements will be added.
      $element['value']['#attributes']['class'][] = 'form-text';
      $element['value']['#attributes']['autocomplete'][] = 'tel';
      break;

    case 'field_profile_address':
      // @todo Remove this when script for custom selects will be added.
      $element['country_code']['#attributes']['class'][] = 'browser-default';
      break;

    case 'field_profile_nick_name':
      $element['value']['#attributes']['autocomplete'][] = 'nickname';
      break;

    case 'field_profile_first_name':
      $element['value']['#attributes']['autocomplete'][] = 'given-name';
      break;

    case 'field_profile_last_name':
      $element['value']['#attributes']['autocomplete'][] = 'family-name';
      break;

    case 'field_profile_organization':
      $element['value']['#attributes']['autocomplete'][] = 'organization';
      break;

    case 'field_profile_function':
      $element['value']['#attributes']['autocomplete'][] = 'organization-title';
      break;
  }

  // This replaces all user entity references with our EntityReferenceSelection.
  if ($field_definition->getType() === 'entity_reference') {
    if (