Skip to content

Commit

Permalink
Merge pull request #1330 from silverstripe-terraformers/feature/injec…
Browse files Browse the repository at this point in the history
…table-config

ENH: Injectable GridField config components.
  • Loading branch information
GuySartorelli authored Sep 24, 2024
2 parents fa8f798 + 2d6423e commit a80265a
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions code/Extension/UserFormFieldEditorExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function updateCMSFields(FieldList $fields)
{
$fieldEditor = $this->getFieldEditorGrid();

$fields->insertAfter('Main', new Tab('FormFields', _t(__CLASS__.'.FORMFIELDS', 'Form Fields')));
$fields->insertAfter('Main', Tab::create('FormFields', _t(__CLASS__.'.FORMFIELDS', 'Form Fields')));
$fields->addFieldToTab('Root.FormFields', $fieldEditor);

return $fields;
Expand All @@ -81,7 +81,7 @@ public function getFieldEditorGrid()

$this->createInitialFormStep(true);

$editableColumns = new GridFieldEditableColumns();
$editableColumns = GridFieldEditableColumns::create();
$fieldClasses = singleton(EditableFormField::class)->getEditableFieldClasses();
$editableColumns->setDisplayFields([
'ClassName' => function ($record, $column, $grid) use ($fieldClasses) {
Expand All @@ -103,7 +103,7 @@ public function getFieldEditorGrid()
$config = GridFieldConfig::create()
->addComponents(
$editableColumns,
new GridFieldButtonRow(),
GridFieldButtonRow::create(),
(new GridFieldAddClassesButton(EditableTextField::class))
->setButtonName(_t(__CLASS__.'.ADD_FIELD', 'Add Field'))
->setButtonClass('btn-primary'),
Expand All @@ -113,13 +113,13 @@ public function getFieldEditorGrid()
(new GridFieldAddClassesButton([EditableFieldGroup::class, EditableFieldGroupEnd::class]))
->setButtonName(_t(__CLASS__.'.ADD_FIELD_GROUP', 'Add Field Group'))
->setButtonClass('btn-secondary'),
$editButton = new GridFieldEditButton(),
new GridFieldDeleteAction(),
new GridFieldToolbarHeader(),
new GridFieldOrderableRows('Sort'),
new GridFieldDetailForm(),
$editButton = GridFieldEditButton::create(),
GridFieldDeleteAction::create(),
GridFieldToolbarHeader::create(),
GridFieldOrderableRows::create('Sort'),
GridFieldDetailForm::create(),
// Betterbuttons prev and next is enabled by adding a GridFieldPaginator component
new GridFieldPaginator(999)
GridFieldPaginator::create(999)
);

$editButton->removeExtraClass('grid-field__icon-action--hidden-on-hover');
Expand Down

0 comments on commit a80265a

Please sign in to comment.