Merge pull request #621 from creative-commoners/pulls/4.2/fix-submissions-gridfield-state

FIX Pass submissions GridFieldConfig to GridField constructor to avoid error in state
This commit is contained in:
Franco Springveldt 2017-06-26 18:07:24 +12:00 committed by GitHub
commit 08b0a74124

View File

@ -125,7 +125,6 @@ class UserDefinedForm extends Page
$self = $this;
$this->beforeUpdateCMSFields(function ($fields) use ($self) {
// define tabs
$fields->findOrMakeTab('Root.FormOptions', _t('UserDefinedForm.CONFIGURATION', 'Configuration'));
$fields->findOrMakeTab('Root.Recipients', _t('UserDefinedForm.RECIPIENTS', 'Recipients'));
@ -167,12 +166,6 @@ class UserDefinedForm extends Page
// view the submissions
$submissions = new GridField(
'Submissions',
_t('UserDefinedForm.SUBMISSIONS', 'Submissions'),
$self->Submissions()->sort('Created', 'DESC')
);
// make sure a numeric not a empty string is checked against this int column for SQL server
$parentID = (!empty($self->ID)) ? (int) $self->ID : 0;
@ -229,10 +222,20 @@ SQL;
$export->setCsvHasHeader(true);
$export->setExportColumns($columns);
$submissions->setConfig($config);
$submissions = GridField::create(
'Submissions',
_t('UserDefinedForm.SUBMISSIONS', 'Submissions'),
$self->Submissions()->sort('Created', 'DESC'),
$config
);
$fields->addFieldToTab('Root.Submissions', $submissions);
$fields->addFieldToTab('Root.FormOptions', new CheckboxField('DisableSaveSubmissions', _t('UserDefinedForm.SAVESUBMISSIONS', 'Disable Saving Submissions to Server')));
$fields->addFieldToTab(
'Root.FormOptions',
CheckboxField::create(
'DisableSaveSubmissions',
_t('UserDefinedForm.SAVESUBMISSIONS', 'Disable Saving Submissions to Server')
)
);
});
$fields = parent::getCMSFields();