mirror of
https://github.com/silverstripe/silverstripe-userforms.git
synced 2024-10-22 17:05:42 +02:00
Make sure option gridfield is created before the UpdateCMSFields function so we can override fields in extensions
This commit is contained in:
parent
aa171f8e45
commit
8af5ff93c3
@ -33,50 +33,52 @@ class EditableMultipleOptionField extends EditableFormField
|
|||||||
*/
|
*/
|
||||||
public function getCMSFields()
|
public function getCMSFields()
|
||||||
{
|
{
|
||||||
$fields = parent::getCMSFields();
|
$this->beforeUpdateCMSFields(function($fields) {
|
||||||
|
$editableColumns = new GridFieldEditableColumns();
|
||||||
|
$editableColumns->setDisplayFields(array(
|
||||||
|
'Title' => array(
|
||||||
|
'title' => _t('EditableMultipleOptionField.TITLE', 'Title'),
|
||||||
|
'callback' => function ($record, $column, $grid) {
|
||||||
|
return TextField::create($column);
|
||||||
|
}
|
||||||
|
),
|
||||||
|
'Value' => array(
|
||||||
|
'title' => _t('EditableMultipleOptionField.VALUE', 'Value'),
|
||||||
|
'callback' => function ($record, $column, $grid) {
|
||||||
|
return TextField::create($column);
|
||||||
|
}
|
||||||
|
),
|
||||||
|
'Default' => array(
|
||||||
|
'title' => _t('EditableMultipleOptionField.DEFAULT', 'Selected by default?'),
|
||||||
|
'callback' => function ($record, $column, $grid) {
|
||||||
|
return CheckboxField::create($column);
|
||||||
|
}
|
||||||
|
)
|
||||||
|
));
|
||||||
|
|
||||||
$editableColumns = new GridFieldEditableColumns();
|
$optionsConfig = GridFieldConfig::create()
|
||||||
$editableColumns->setDisplayFields(array(
|
->addComponents(
|
||||||
'Title' => array(
|
new GridFieldToolbarHeader(),
|
||||||
'title' => _t('EditableMultipleOptionField.TITLE', 'Title'),
|
new GridFieldTitleHeader(),
|
||||||
'callback' => function ($record, $column, $grid) {
|
new GridFieldOrderableRows('Sort'),
|
||||||
return TextField::create($column);
|
$editableColumns,
|
||||||
}
|
new GridFieldButtonRow(),
|
||||||
),
|
new GridFieldAddNewInlineButton(),
|
||||||
'Value' => array(
|
new GridFieldDeleteAction()
|
||||||
'title' => _t('EditableMultipleOptionField.VALUE', 'Value'),
|
);
|
||||||
'callback' => function ($record, $column, $grid) {
|
|
||||||
return TextField::create($column);
|
|
||||||
}
|
|
||||||
),
|
|
||||||
'Default' => array(
|
|
||||||
'title' => _t('EditableMultipleOptionField.DEFAULT', 'Selected by default?'),
|
|
||||||
'callback' => function ($record, $column, $grid) {
|
|
||||||
return CheckboxField::create($column);
|
|
||||||
}
|
|
||||||
)
|
|
||||||
));
|
|
||||||
|
|
||||||
$optionsConfig = GridFieldConfig::create()
|
$optionsGrid = GridField::create(
|
||||||
->addComponents(
|
'Options',
|
||||||
new GridFieldToolbarHeader(),
|
_t('EditableFormField.CUSTOMOPTIONS', 'Options'),
|
||||||
new GridFieldTitleHeader(),
|
$this->Options(),
|
||||||
new GridFieldOrderableRows('Sort'),
|
$optionsConfig
|
||||||
$editableColumns,
|
|
||||||
new GridFieldButtonRow(),
|
|
||||||
new GridFieldAddNewInlineButton(),
|
|
||||||
new GridFieldDeleteAction()
|
|
||||||
);
|
);
|
||||||
|
|
||||||
$optionsGrid = GridField::create(
|
$fields->insertAfter(new Tab('Options', _t('EditableMultipleOptionField.OPTIONSTAB', 'Options')), 'Main');
|
||||||
'Options',
|
$fields->addFieldToTab('Root.Options', $optionsGrid);
|
||||||
_t('EditableFormField.CUSTOMOPTIONS', 'Options'),
|
});
|
||||||
$this->Options(),
|
|
||||||
$optionsConfig
|
|
||||||
);
|
|
||||||
|
|
||||||
$fields->insertAfter(new Tab('Options', _t('EditableMultipleOptionField.OPTIONSTAB', 'Options')), 'Main');
|
$fields = parent::getCMSFields();
|
||||||
$fields->addFieldToTab('Root.Options', $optionsGrid);
|
|
||||||
|
|
||||||
return $fields;
|
return $fields;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user