I'd like to use a hook to modify a widget, but only for a named field.
Use case: a form has an entity reference to another content type, using an options_buttons widget (a list of available courses the user can apply for). Rather than just the title alongside each checkbox, I'd like to display some extra fields from the content type such as date, a URL etc.
The documentation suggests
$context['widget'] ("The widget plugin instance.") is the place to look, however a var_dump of that just seems to give me lots of protected properties and no clear way of getting the field name.
Essentially I'm after a D8 version similar to this old example I found:
if ($context['field']['field_name'] != 'field_bannerimage') return;