I'm using the buttons method to add more paragraphs and am styling the buttons via css in a custom module. I'm setting paragraph icons as background images for each button so an editor can visually see what they will be adding with each button.
I can accomplish this via css by using:
input.button.field-add-more-submit[value="Add My Great Paragraph"]{
background-image: //my icon
}
but am looking for a more bulletproof way to styles these buttons than the value. I'd like to add the paragraph bundle type machine name to the input as a class (in case the label of the paragraph type changes down the road).
I can access the paragraphs field widget by using a widget form alter but haven't been able to get to the buttons from there.
function my_custom_module_field_widget_form_alter(&$element, \Drupal\Core\Form\FormStateInterface $form_state, $context) {
$field_definition = $context['items']->getFieldDefinition();
if ($field_definition->getType() == 'entity_reference_revisions') {
//can access the paragraphs field here but not the buttons
}
}
Any ideas would be helpful, thanks.