mirror of
https://github.com/silverstripe/silverstripe-userforms.git
synced 2024-10-22 17:05:42 +02:00
ENH: Injectable GridField config components.
This commit is contained in:
parent
fa8f7984af
commit
2d6423e3d0
@ -60,7 +60,7 @@ class UserFormFieldEditorExtension extends DataExtension
|
|||||||
{
|
{
|
||||||
$fieldEditor = $this->getFieldEditorGrid();
|
$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);
|
$fields->addFieldToTab('Root.FormFields', $fieldEditor);
|
||||||
|
|
||||||
return $fields;
|
return $fields;
|
||||||
@ -81,7 +81,7 @@ class UserFormFieldEditorExtension extends DataExtension
|
|||||||
|
|
||||||
$this->createInitialFormStep(true);
|
$this->createInitialFormStep(true);
|
||||||
|
|
||||||
$editableColumns = new GridFieldEditableColumns();
|
$editableColumns = GridFieldEditableColumns::create();
|
||||||
$fieldClasses = singleton(EditableFormField::class)->getEditableFieldClasses();
|
$fieldClasses = singleton(EditableFormField::class)->getEditableFieldClasses();
|
||||||
$editableColumns->setDisplayFields([
|
$editableColumns->setDisplayFields([
|
||||||
'ClassName' => function ($record, $column, $grid) use ($fieldClasses) {
|
'ClassName' => function ($record, $column, $grid) use ($fieldClasses) {
|
||||||
@ -103,7 +103,7 @@ class UserFormFieldEditorExtension extends DataExtension
|
|||||||
$config = GridFieldConfig::create()
|
$config = GridFieldConfig::create()
|
||||||
->addComponents(
|
->addComponents(
|
||||||
$editableColumns,
|
$editableColumns,
|
||||||
new GridFieldButtonRow(),
|
GridFieldButtonRow::create(),
|
||||||
(new GridFieldAddClassesButton(EditableTextField::class))
|
(new GridFieldAddClassesButton(EditableTextField::class))
|
||||||
->setButtonName(_t(__CLASS__.'.ADD_FIELD', 'Add Field'))
|
->setButtonName(_t(__CLASS__.'.ADD_FIELD', 'Add Field'))
|
||||||
->setButtonClass('btn-primary'),
|
->setButtonClass('btn-primary'),
|
||||||
@ -113,13 +113,13 @@ class UserFormFieldEditorExtension extends DataExtension
|
|||||||
(new GridFieldAddClassesButton([EditableFieldGroup::class, EditableFieldGroupEnd::class]))
|
(new GridFieldAddClassesButton([EditableFieldGroup::class, EditableFieldGroupEnd::class]))
|
||||||
->setButtonName(_t(__CLASS__.'.ADD_FIELD_GROUP', 'Add Field Group'))
|
->setButtonName(_t(__CLASS__.'.ADD_FIELD_GROUP', 'Add Field Group'))
|
||||||
->setButtonClass('btn-secondary'),
|
->setButtonClass('btn-secondary'),
|
||||||
$editButton = new GridFieldEditButton(),
|
$editButton = GridFieldEditButton::create(),
|
||||||
new GridFieldDeleteAction(),
|
GridFieldDeleteAction::create(),
|
||||||
new GridFieldToolbarHeader(),
|
GridFieldToolbarHeader::create(),
|
||||||
new GridFieldOrderableRows('Sort'),
|
GridFieldOrderableRows::create('Sort'),
|
||||||
new GridFieldDetailForm(),
|
GridFieldDetailForm::create(),
|
||||||
// Betterbuttons prev and next is enabled by adding a GridFieldPaginator component
|
// 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');
|
$editButton->removeExtraClass('grid-field__icon-action--hidden-on-hover');
|
||||||
|
Loading…
Reference in New Issue
Block a user