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;
|
||||
|
||||
// And generate field
|
||||
$attributes = array(
|
||||
'class' => 'action' . ($this->extraClass() ? $this->extraClass() : ''),
|
||||
'id' => $this->id(),
|
||||
'type' => 'submit',
|
||||
$data = new ArrayData(array(
|
||||
'Class' => 'action' . ($this->extraClass() ? $this->extraClass() : '') . ($this->isReadonly() ? ' disabled' : ''),
|
||||
'ID' => $this->id(),
|
||||
// Note: This field needs to be less than 65 chars, otherwise Suhosin security patch
|
||||
// will strip it from the requests
|
||||
'name' => 'action_gridFieldAlterAction'. '?' . http_build_query($actionData),
|
||||
'tabindex' => $this->getTabIndex(),
|
||||
);
|
||||
'Name' => 'action_gridFieldAlterAction'. '?' . http_build_query($actionData),
|
||||
'Disabled' => $this->isReadonly(),
|
||||
'Label' => $this->buttonLabel
|
||||
));
|
||||
|
||||
if($this->isReadonly()) {
|
||||
$attributes['disabled'] = 'disabled';
|
||||
$attributes['class'] = $attributes['class'] . ' disabled';
|
||||
}
|
||||
|
||||
return $this->createTag('button', $attributes, $this->buttonLabel);
|
||||
return $data->renderWith('GridField_Action');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -69,7 +69,11 @@ class GridFieldAction_Edit implements GridField_ColumnProvider {
|
||||
* @return string - the HTML for the column
|
||||
*/
|
||||
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