Development

Make a Field Label “visually-hidden” in Drupal 8

Using the Form API you can add a visually-hidden class to a field using the “#title_display” property as shown here:

 

One Comment

  • Travis Miller

    This doesn’t work for me. My $form doesn’t even have a key named ‘keys’.

    The closest thing I can find in the $form array is $form[‘my_field_name’][‘widget’][0][‘#title_display’] – which has a value of “before”. But, changing this value doesn’t seem to affect anything.

Leave a Reply

Your email address will not be published.