unclecheese / silverstripe-gridfield-betterbuttons

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

onBeforeWrite() is not called by "Save and close" #139

Open minimalic opened 8 years ago

minimalic commented 8 years ago

The function onBeforeWrite() works on DataObject with "Save" but not with "Save and close". Is this problem already known?

silverstripe-elliot commented 7 years ago

Any updates on this? I have a Dataobject which is saving correctly with the "Save" button, but does not save correctly with "Save and close". The feature is a checkbox on manyManyExtra Fields, and the DO attempts to validate() that object by checking the value.

This is within a custom GridFieldDetailForm, so I worked around it by disabling BetterButtons specifically for that form:

    public function getCMSFields(){
            ...
            $myDataObject = singleton('MyDataObject');

            //BetterButtons "Save and Close" doesn't work on this custom GridFieldDetailForm, so disable it
            //see @link https://github.com/unclecheese/silverstripe-gridfield-betterbuttons/issues/139
            $myDataObject->config()->better_buttons_enabled = false;
            ...