Skip to content

Commit

Permalink
Merge pull request #71 from stevie-mayhew/feature/disable_buttons
Browse files Browse the repository at this point in the history
FEATURE: allow better buttons to be entirely disabled on certain dataobjects
  • Loading branch information
unclecheese committed Nov 20, 2014
2 parents c364d1f + dac2d1a commit a164a0f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,3 +190,11 @@ Sometimes, you might not want to sent a request to the controller at all. For th

![Screenshot](http://i.cubeupload.com/YbbhL7.png)

### Disabling Better Buttons

Sometimes you might find it necessary to disable better buttons on certain classes. You can do this by changing the static `better_buttons_enabled` to be false via YML configuration.

```yml
MyBetterButtonLessClass
better_buttons_enabled: false
```
7 changes: 7 additions & 0 deletions code/extensions/BetterButtonDataObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@
*/
class BetterButtonDataObject extends DataExtension {

/**
* Enable better buttons for this DataObject
*
* @config
* @var bool
*/
private static $better_buttons_enabled = true;

/**
* Gets the default actions for all DataObjects. Can be overloaded in subclasses
Expand Down
3 changes: 3 additions & 0 deletions code/extensions/GridFieldBetterButtonsItemRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ public function addnew(SS_HTTPRequest $r) {
* @param Form The ItemEditForm object
*/
public function updateItemEditForm($form) {
if ($this->getRecord()->stat('better_buttons_enabled') !== true) {
return false;
}
Requirements::css(BETTER_BUTTONS_DIR.'/css/gridfield_betterbuttons.css');
Requirements::javascript(BETTER_BUTTONS_DIR.'/javascript/gridfield_betterbuttons.js');

Expand Down

2 comments on commit a164a0f

@ARNHOE
Copy link
Contributor

@ARNHOE ARNHOE commented on a164a0f Nov 21, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fatal error: Call to undefined method GridFieldBetterButtonsItemRequest::getRecord() in /betterbuttons/code/extensions/GridFieldBetterButtonsItemRequest.php on line 73

Using default yml

@phillprice
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seconded

Please sign in to comment.