mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
ENHANCEMENT SSF-53 : Change the Labels for "Save" and "Delete" button for an "adding new form" of GridField to "Create" and "Cancel", apply different logic for Cancel
This commit is contained in:
parent
5d4d0dba05
commit
1facb509a4
@ -223,16 +223,33 @@ class GridFieldPopupForm_ItemRequest extends RequestHandler {
|
|||||||
return Director::redirect($noActionURL, 302);
|
return Director::redirect($noActionURL, 302);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$actions = new FieldList();
|
||||||
|
if($this->record->ID !== 0) {
|
||||||
|
$actions->push(FormAction::create('doSave', _t('GridFieldDetailsForm.Save', 'Save'))
|
||||||
|
->setUseButtonTag(true)->addExtraClass('ss-ui-action-constructive')->setAttribute('data-icon', 'accept'));
|
||||||
|
$actions->push(FormAction::create('doDelete', _t('GridFieldDetailsForm.Delete', 'Delete'))
|
||||||
|
->addExtraClass('ss-ui-action-destructive'));
|
||||||
|
}else{ // adding new record
|
||||||
|
//Change the Save label to 'Create'
|
||||||
|
$actions->push(FormAction::create('doSave', _t('GridFieldDetailsForm.Create', 'Create'))
|
||||||
|
->setUseButtonTag(true)->addExtraClass('ss-ui-action-constructive')->setAttribute('data-icon', 'add'));
|
||||||
|
|
||||||
|
// Add a Cancel link which is a button-like link and link back to one level up.
|
||||||
|
$curmbs = $this->Breadcrumbs();
|
||||||
|
if($curmbs->count()>=2){
|
||||||
|
$one_level_up = $curmbs->offsetGet($curmbs->count()-2);
|
||||||
|
$text = "
|
||||||
|
<a class=\"crumb ss-ui-button ss-ui-action-destructive cms-panel-link ui-corner-all\" href=\"".$one_level_up->Link."\">
|
||||||
|
Cancel
|
||||||
|
</a>";
|
||||||
|
$actions->push(new LiteralField('cancelbutton', $text));
|
||||||
|
}
|
||||||
|
}
|
||||||
$form = new Form(
|
$form = new Form(
|
||||||
$this,
|
$this,
|
||||||
'ItemEditForm',
|
'ItemEditForm',
|
||||||
$this->record->getCMSFields(),
|
$this->record->getCMSFields(),
|
||||||
new FieldList(
|
$actions,
|
||||||
FormAction::create('doSave', _t('GridFieldDetailsForm.Save', 'Save'))
|
|
||||||
->addExtraClass('ss-ui-action-constructive')->setAttribute('data-icon', 'accept'),
|
|
||||||
FormAction::create('doDelete', _t('GridFieldDetailsForm.Delete', 'Delete'))
|
|
||||||
->addExtraClass('ss-ui-action-destructive')
|
|
||||||
),
|
|
||||||
$this->component->getValidator()
|
$this->component->getValidator()
|
||||||
);
|
);
|
||||||
$form->loadDataFrom($this->record);
|
$form->loadDataFrom($this->record);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user