So I have a module that defines a custom field which I need to style.
It seems the right way to accomplish is to define a library in my module and then refer to it through the '#attached' property.
Which I did, but the css file is not being loaded (I've cleared the cache, reinstall the module, no avail.) No network error, or other error of any kind. The file just isn't loaded.
Here's the relevant parts of my code:
swan_fields_pt_zipcode.libraries.yml
zipcode_widget:
css:
component:
'css/zipcodewidget.layout.css': {}
swan_fields_pt_zipcode.info.yml
name: Swan Fields PT ZipCode
type: module
core: 8.x
libraries:
- 'swan_fields_pt_zipcode/zipcode_widget'
WidgetInterface implementation:
public function formElement(
FieldItemListInterface $items,
$delta,
array $element,
array &$form,
FormStateInterface $form_state
) {
// ...
// ...form definition and stuff
$element['insidecontainer']['#attached']['library'][] = 'swan_fields_pt_zipcode/zipcode_widget';
}
What am I missing?