processwire / processwire-requests

ProcessWire feature requests.
39 stars 0 forks source link

Add option to Inputfield header action functions to add custom class to action button #542

Open Toutouwai opened 1 week ago

Toutouwai commented 1 week ago

Short description of the enhancement

There are JS and PHP functions for adding Inputfield header action buttons, most recently mentioned in this announcement: https://processwire.com/talk/topic/30226-weekly-update-%E2%80%93%C2%A019-july-2024/

This request is to add an option that allows a custom class to be added to an action button (icon), so that it can be targeted in custom CSS and JS.

So that you could do something like this:

$inputfield->addHeaderAction([
    'icon' => 'question-circle',
    'href' => $this->wire()->config->urls->root . "admin-docs/?id=$doc_id",
    'class' => 'my-custom-action',
]);

...and get markup like this...

2024-09-20_203402

Toutouwai commented 1 week ago

It would also be good to be able to add custom data attributes to the buttons - more important than classes actually, because if custom data attributes were possible we could always target icons via data attribute in CSS and JS.