Skip to content

Commit

Permalink
Enable 4.4 better button functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
RVXD committed Jul 8, 2019
1 parent 1386f1b commit f682e74
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
4 changes: 3 additions & 1 deletion code/Extension/UserFormFieldEditorExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace SilverStripe\UserForms\Extension;

use SilverStripe\Forms\FieldList;
use SilverStripe\Forms\GridField\GridFieldPaginator;
use SilverStripe\Forms\Tab;
use SilverStripe\Forms\GridField\GridField;
use SilverStripe\Forms\GridField\GridFieldButtonRow;
Expand Down Expand Up @@ -103,7 +104,8 @@ public function getFieldEditorGrid()
new GridFieldDeleteAction(),
new GridFieldToolbarHeader(),
new GridFieldOrderableRows('Sort'),
new GridFieldDetailForm(null, false, false)
new GridFieldDetailForm(),
new GridFieldPaginator(999)
);

$editButton->removeExtraClass('grid-field__icon-action--hidden-on-hover');
Expand Down
10 changes: 10 additions & 0 deletions code/Model/EditableFormField.php
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,16 @@ public function getCMSFields()
{
$fields = FieldList::create(TabSet::create('Root'));

// If created with (+) button
if ($this->ClassName === EditableFormField::class) {
$fieldClasses = $this->getEditableFieldClasses();
$fields->addFieldsToTab('Root.Main', [
DropdownField::create('ClassName', _t(__CLASS__.'.TYPE', 'Type'), $fieldClasses)
->setEmptyString(_t(__CLASS__ . 'TYPE_EMPTY', 'Select field type'))
]);
return $fields;
}

// Main tab
$fields->addFieldsToTab(
'Root.Main',
Expand Down
2 changes: 1 addition & 1 deletion code/UserForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ public function getCMSFields()
$config->addComponent(new GridFieldDeleteAction());
$config->addComponent(new GridFieldPageCount('toolbar-header-right'));
$config->addComponent($pagination = new GridFieldPaginator(25));
$config->addComponent(new GridFieldDetailForm(null, null, false));
$config->addComponent(new GridFieldDetailForm()); // RVXD
$config->addComponent(new GridFieldButtonRow('after'));
$config->addComponent($export = new GridFieldExportButton('buttons-after-left'));
$config->addComponent($print = new GridFieldPrintButton('buttons-after-left'));
Expand Down

0 comments on commit f682e74

Please sign in to comment.