Skip to main content

Working with Drupal field widgets

Field widgets are how you collect the content of your fields within Drupal, there's a wide range of options available depending of the type of field you're working with. So something like a data field might give you the option of inputting the appropriate data either as a text field, a date dropdown or even a calendar dropdown. Different fields have different widgets which are appropriate for them and of course you can look to the Drupal community for more or even create your own! Below are a selection of our articles on Drupal field widgets....

Read some of our articles about Drupal field widgets

Language lessons: How can I fix my autocomplete box?

10th Nov 2015

Languages make everything so complicated! I just discovered the autocomplete bit on my reference fields wasn't working - until I tried searching by another language, and then the results gave me a surprise:

Autocomplete results are not in the same language as their search input for entity reference fields

 

My homepage, originally in French, has had an English translation added, but whilst editing in English, I had to search with the French title in order for the page to come up... with the English title! Here's how to solve this...

My site uses Entity translation and the Title module (which I usually recommend as the best way of making your site translatable), and this...

Read more

Drupal 8: Creating a custom field - Part 2: Field drupal widget

Jo Fitzgerald
4th Feb 2014

This is part 2 in my series of articles about Drupal widgets, and specifically creating a custom field. I recommend reading Part 1: Field type first, if you have not done so already.

After creating the field type it is now time to create the field widget.

##a) Create the file
The field widget must be located as follows:

<module_name>/lib/Drupal/<module_name>/Plugin/field/widget/<field_widget_name>.php</field_widget_name></module_name></module_name>

N.B. The field widget name should be in CamelCase.

##b) Add Contains, namespace and use
In the newly created field type file add a brief comment to explain what it consists of:


/**
 * @file
 *...
Read more