mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-06-27 15:09:30 +02:00
cc712892a9
* MINOR: Add `Previous`, `Next` and `Create New` actions in edit form If the form is opened via a grid field, the filters will be retained so the previous/next record opened will be correct * MINOR: Add ability to customise the visibility of the `Previous`, `Next` and `Add` buttons at a `GridField` level * Fix invalid action when pressing the `New` button in an edit form unless `betterbuttons` module was installed * - Merge `showPrevious` and `showNext` to `showPagination` for grid fields - Update documentation - Improve performance for next/previous buttons by not fetching all list records - Refactoring * Refactor to fail gracefully on GridFieldPaginator
40 lines
1.7 KiB
PHP
40 lines
1.7 KiB
PHP
<?php
|
|
namespace SilverStripe\Forms\GridField;
|
|
|
|
/**
|
|
* Allows editing of records contained within the GridField, instead of only allowing the ability to view records in
|
|
* the GridField.
|
|
*/
|
|
class GridFieldConfig_RecordEditor extends GridFieldConfig
|
|
{
|
|
/**
|
|
*
|
|
* @param int $itemsPerPage - How many items per page should show up
|
|
* @param bool $showPagination Whether the `Previous` and `Next` buttons should display or not, leave as null to use default
|
|
* @param bool $showAdd Whether the `Add` button should display or not, leave as null to use default
|
|
*/
|
|
public function __construct($itemsPerPage = null, $showPagination = null, $showAdd = null)
|
|
{
|
|
parent::__construct();
|
|
|
|
$this->addComponent(new GridFieldButtonRow('before'));
|
|
$this->addComponent(new GridFieldAddNewButton('buttons-before-left'));
|
|
$this->addComponent(new GridFieldToolbarHeader());
|
|
$this->addComponent($sort = new GridFieldSortableHeader());
|
|
$this->addComponent($filter = new GridFieldFilterHeader());
|
|
$this->addComponent(new GridFieldDataColumns());
|
|
$this->addComponent(new GridFieldEditButton());
|
|
$this->addComponent(new GridFieldDeleteAction());
|
|
$this->addComponent(new GridField_ActionMenu());
|
|
$this->addComponent(new GridFieldPageCount('toolbar-header-right'));
|
|
$this->addComponent($pagination = new GridFieldPaginator($itemsPerPage));
|
|
$this->addComponent(new GridFieldDetailForm(null, $showPagination, $showAdd));
|
|
|
|
$sort->setThrowExceptionOnBadDataType(false);
|
|
$filter->setThrowExceptionOnBadDataType(false);
|
|
$pagination->setThrowExceptionOnBadDataType(false);
|
|
|
|
$this->extend('updateConfig');
|
|
}
|
|
}
|