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

View File

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

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>