elofgren: Add 'extraClass' parameter to FormAction? and use it to assign the 'delete' CSS class to the 'Unpublish' and 'Cancel draft changes' buttons so that their background turns red on hover.

(merged from branches/gsoc)


git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@41820 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Ingo Schommer 2007-09-14 23:43:02 +00:00
parent 3be2d445f9
commit ef54473d1b
2 changed files with 7 additions and 5 deletions

View File

@ -738,11 +738,11 @@ class SiteTree extends DataObject {
function getCMSActions() { function getCMSActions() {
$actions = array(); $actions = array();
if($this->isPublished() && $this->canPublish()) { if($this->isPublished() && $this->canPublish()) {
$actions[] = FormAction::create('unpublish', 'Unpublish')->describe("Remove this page from the published site"); $actions[] = FormAction::create('unpublish', 'Unpublish', 'delete')->describe("Remove this page from the published site");
} }
if($this->stagesDiffer('Stage','Live')) { if($this->stagesDiffer('Stage','Live')) {
if($this->isPublished() && $this->canEdit()) { if($this->isPublished() && $this->canEdit()) {
$actions[] = FormAction::create('rollback', 'Cancel draft changes')->describe("Delete your draft and revert to the currently published page"); $actions[] = FormAction::create('rollback', 'Cancel draft changes', 'delete')->describe("Delete your draft and revert to the currently published page");
} }
} }

View File

@ -14,13 +14,15 @@ class FormAction extends FormField {
* @param form The parent form, auto-set when the field is placed inside a form * @param form The parent form, auto-set when the field is placed inside a form
* @param extraData A piece of extra data that can be extracted with $this->extraData. Useful for * @param extraData A piece of extra data that can be extracted with $this->extraData. Useful for
* calling $form->buttonClicked()->extraData() * calling $form->buttonClicked()->extraData()
* @param extraClass A CSS class to apply to the button in addition to 'action'
*/ */
function __construct($action, $title = "", $form = null, $extraData = null) { function __construct($action, $title = "", $form = null, $extraData = null, $extraClass = '') {
$this->extraData = $extraData; $this->extraData = $extraData;
$this->extraClass = ' '.$extraClass;
parent::__construct("action_$action", $title, null, $form); parent::__construct("action_$action", $title, null, $form);
} }
static function create($action, $title = "", $extraData = null) { static function create($action, $title = "", $extraData = null, $extraClass = null) {
return new FormAction($action, $title, $extraData); return new FormAction($action, $title, null, $extraData, $extraClass);
} }
function actionName() { function actionName() {