Skip to content

Commit

Permalink
Update 4.2 branch to php 7 and replace sortablegridfield with gridfie…
Browse files Browse the repository at this point in the history
…ldextensions
  • Loading branch information
tractorcow committed Feb 7, 2020
1 parent 987842a commit eaf8454
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ CatalogPage:

#### Drag and drop sorting

You can add drag and drop sorting using GridFieldSortableRows when you add the `sort_column` setting to your configuration.
You can add drag and drop sorting using GridFieldOrderableRows when you add the `sort_column` setting to your configuration.
Uses column `Sort` by default which is default in SiteTree and is added by CatalogDataObjectExtension.

```yml
Expand Down
5 changes: 3 additions & 2 deletions code/ModelAdmin/CatalogPageAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public function init()
*/
public function getEditForm($id = null, $fields = null)
{
/** @var DataObject|CatalogPageExtension|CatalogDataObjectExtension $model */
$model = singleton($this->modelClass);
if ($model->has_extension('CatalogPageExtension') || $model->has_extension('CatalogDataObjectExtension')) {
$list = $this->getList()->setDataQueryParam(array(
Expand Down Expand Up @@ -66,8 +67,8 @@ public function getEditForm($id = null, $fields = null)
$form->setAttribute('data-pjax-fragment', 'CurrentForm');

/** add sorting if we have a field for... */
if (class_exists('GridFieldSortableRows') && $sortField = $model->getSortFieldname()) {
$fieldConfig->addComponent(new GridFieldSortableRows($sortField));
if ($sortField = $model->getSortFieldname()) {
$fieldConfig->addComponent(new GridFieldOrderableRows($sortField));
}
} elseif (method_exists($model, 'getAdminListField')) {
$form = CMSForm::create(
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
}
],
"require": {
"undefinedoffset/sortablegridfield": "^0.6.0",
"php": "^7",
"symbiote/silverstripe-gridfieldextensions": "^2",
"silverstripe/cms": "^3.4",
"unclecheese/betterbuttons": "^1.3.7"

}
}

0 comments on commit eaf8454

Please sign in to comment.