Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hey this is my first issue/patch not sure if I am doing it right or not.
Currently in D8 I could not find a way to style the flag with an image. The flag when clicked would not supply me with anything I could use, and I was stuck either using some janky javascript to check the text and add my own Css class, or edit the AJAXactionLink file and add my own class based on the action of the flag.
/**
* {@inheritdoc}
*/
public function buildLink($action, FlagInterface $flag, EntityInterface $entity) {
$render = parent::buildLink($action, $flag, $entity);
$render['#attached']['library'][] = 'core/drupal.ajax';
$render['#attributes']['class'][] = 'use-ajax';
$render['#attributes']['class'][] = $action; /**Adding This line enabled me to style the flag **/
$render['#url']->setRouteParameter('_format', 'json');
return $render;
}
Adding the above line allowed me to implement my own style for the flag.
Comments
Comment #2
joachim CreditAttribution: joachim commentedI think there's already an issue for adding a template for the flag link -- can you check please?
(BTW: please don't use tags for adding random keywords or duplicating any other fields.)
Comment #3
socketwench CreditAttribution: socketwench as a volunteer commentedClosing as this is a duplicate.