mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
MINOR Move gridfield actions HTML to templates
This commit is contained in:
parent
0acaf39664
commit
b389138f50
@ -709,22 +709,17 @@ class GridField_Action extends FormAction {
|
|||||||
$actionData['StateID'] = $id;
|
$actionData['StateID'] = $id;
|
||||||
|
|
||||||
// And generate field
|
// And generate field
|
||||||
$attributes = array(
|
$data = new ArrayData(array(
|
||||||
'class' => 'action' . ($this->extraClass() ? $this->extraClass() : ''),
|
'Class' => 'action' . ($this->extraClass() ? $this->extraClass() : '') . ($this->isReadonly() ? ' disabled' : ''),
|
||||||
'id' => $this->id(),
|
'ID' => $this->id(),
|
||||||
'type' => 'submit',
|
|
||||||
// Note: This field needs to be less than 65 chars, otherwise Suhosin security patch
|
// Note: This field needs to be less than 65 chars, otherwise Suhosin security patch
|
||||||
// will strip it from the requests
|
// will strip it from the requests
|
||||||
'name' => 'action_gridFieldAlterAction'. '?' . http_build_query($actionData),
|
'Name' => 'action_gridFieldAlterAction'. '?' . http_build_query($actionData),
|
||||||
'tabindex' => $this->getTabIndex(),
|
'Disabled' => $this->isReadonly(),
|
||||||
);
|
'Label' => $this->buttonLabel
|
||||||
|
));
|
||||||
|
|
||||||
if($this->isReadonly()) {
|
return $data->renderWith('GridField_Action');
|
||||||
$attributes['disabled'] = 'disabled';
|
|
||||||
$attributes['class'] = $attributes['class'] . ' disabled';
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->createTag('button', $attributes, $this->buttonLabel);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -69,7 +69,11 @@ class GridFieldAction_Edit implements GridField_ColumnProvider {
|
|||||||
* @return string - the HTML for the column
|
* @return string - the HTML for the column
|
||||||
*/
|
*/
|
||||||
public function getColumnContent($gridField, $record, $columnName) {
|
public function getColumnContent($gridField, $record, $columnName) {
|
||||||
return sprintf('<a class="action-edit" href="%s">%s</a> ', Controller::join_links($gridField->Link('item'), $record->ID, 'edit'), _t('GridAction.Edit', 'edit'));
|
$data = new ArrayData(array(
|
||||||
|
'Link' => Controller::join_links($gridField->Link('item'), $record->ID, 'edit')
|
||||||
|
));
|
||||||
|
|
||||||
|
return $data->renderWith('GridFieldAction_Edit');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
1
templates/Includes/GridFieldAction_Edit.ss
Normal file
1
templates/Includes/GridFieldAction_Edit.ss
Normal file
@ -0,0 +1 @@
|
|||||||
|
<a class="action-edit" href="$Link">edit</a>
|
1
templates/Includes/GridField_Action.ss
Normal file
1
templates/Includes/GridField_Action.ss
Normal file
@ -0,0 +1 @@
|
|||||||
|
<button id="$ID" class="$Class" name="$Name" type="submit"<% if Disabled %> disabled="disabled"<% end_if %>>$Label</button>
|
Loading…
Reference in New Issue
Block a user