MINOR Move gridfield actions HTML to templates

This commit is contained in:
Andrew O'Neil 2012-02-22 16:19:45 +13:00
parent 0acaf39664
commit b389138f50
4 changed files with 15 additions and 14 deletions

View File

@ -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');
}
/**

View File

@ -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');
}
/**

View File

@ -0,0 +1 @@
<a class="action-edit" href="$Link">edit</a>

View File

@ -0,0 +1 @@
<button id="$ID" class="$Class" name="$Name" type="submit"<% if Disabled %> disabled="disabled"<% end_if %>>$Label</button>