$Hi

Is it possible to load a library with hook_field_widget_form?
E.g.

function hook_widget_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {

$widget['#attached']['libraries_load'][] = array('library_name');
//OR
$widget['#attached'][] = array(
		  'library' => array(
		    array('module_name', 'library_name'),
		  ),
		);

return $widget;

At least my implementation didn't work so I got wondering that is it even possible?
After all this should be a "form" or at least part of it so therefore it should be processed the same way?

Comments

ETENTION created an issue. See original summary.

ETENTION’s picture

tstoeckler’s picture

Status: Active » Fixed

The first option you mention should actually work fine.

If it doesn't please provide some actual code so I can reproduce the problem. Marking fixed in the meantime.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.