unclecheese / silverstripe-gridfield-betterbuttons

Adds new form actions and buttons to the GridField detail form
GNU General Public License v2.0
80 stars 88 forks source link

SS3: BetterButtonCustomAction::performDisabledTransformation() does not disable the button #180

Open Taitava opened 6 years ago

Taitava commented 6 years ago

Example code:

public function getBetterButtonsActions()
{
    $fields = parent::getBetterButtonsActions();
    $my_action = BetterButtonCustomAction::create('MyAction', 'My Action');
    $my_action = $my_action->performDisabledTransformation();
    $fields->push($my_action);
    return $fields;
}

The button appears to be still clickable. The reason is simply because the button is an <a> element in the editor's HTML code. It does have an attribute disabled="disabled" but obviously HTML does not support that for <a> elements.

Could it be simply fixed by making the href attribute empty if the field has the $disabled property set to true?

I haven't tried this in SilverStripe 4. If it works in SS 4, then I guess it's not meaningful to spend much time fixing this in SS 3.