Quick search:


How to add, modify or remove a button

There are two ways to add or remove a button:
1. Override the getButtonsList method on the class of the page where you want to add or remove the button.
2. Specialize the ButtonsPart class for the type, application or all applications.

The first way is the simplest, but it only works for a specific page class. You may have to specialize the page first, see how to specialize a page. From the overriding method, call the super method to get the default button array. It is an array of HTML strings each describing one button. You may add another button string by adding the result of a call to $this->getButton to the array. An example of this is in example 8 (version 1.1, for older versions see example 9). Or you may remove one of the button parts. Then return the array. Of course you can also ignore the default button array entirely and return one built from scratch.

The second way is much more powerful, you can add or remove buttons to/from many pages at once. To specialize the ButtonsPart for a specific type, prefix the name of the new class with the name of the type. For example, to specialize the ButtonsPart for all pages whose type is Employee, create class EmployeeButtonsPart. To specialize the ButtonsPart for all pages of an application, create a class ButtonsPart in the application classFolder. To specialize it for all applications, modify the class ButtonsPart in the root classFolder. Also see how to specialize a part of a page.

To change the layout, caption or script of a button, you may override the addButton method on the page class (You may have to specialize the page first, see how to specialize a page), or modify the string in the array described in "The first way" to add or remove a button.

To change the layout of all buttons, modify the style .funkyButton in style/phppeanuts.css.

To change what happens when a button is pressed, change the script of the button (see above) or find out what page or action handles the request caused by the button script. See how to specialize a page.

There are three special button creation methods, that may be overridden too:
- addContextButtonTo (see how to change the context button behavior)
- getMultiValuePropertyButtonScript,
- addMultiValuePropertyButtons.
As of version 1.1 the behavior of the last can also be influenced by overriding getExcludedMultiValuePropButtonKeys. The overriding method should return an array with with as keys the names of the multi value properties for which no buttons should be added by addMultiValuePropertyButtons.