mirror of
https://github.com/silverstripe/silverstripe-userforms.git
synced 2024-10-22 17:05:42 +02:00
* Fix for #185 and #194 * Fix for #185 and #194 * Fix for #185 and #194
This commit is contained in:
parent
35dca0f62d
commit
8c27891600
@ -205,6 +205,20 @@ SQL;
|
||||
$config->addComponent($export = new GridFieldExportButton('buttons-after-left'));
|
||||
$config->addComponent($print = new GridFieldPrintButton('buttons-after-left'));
|
||||
|
||||
// show user form items in the summary tab
|
||||
$summaryarray = array(
|
||||
'ID' => 'ID',
|
||||
'Created' => 'Created',
|
||||
'LastEdited' => 'Last Edited'
|
||||
);
|
||||
foreach(EditableFormField::get()->filter(array("ParentID" => $parentID)) as $eff) {
|
||||
if($eff->ShowInSummary) {
|
||||
$summaryarray[$eff->Name] = $eff->Title ?: $eff->Name;
|
||||
}
|
||||
}
|
||||
|
||||
$config->getComponentByType('GridFieldDataColumns')->setDisplayFields($summaryarray);
|
||||
|
||||
/**
|
||||
* Support for {@link https://github.com/colymba/GridFieldBulkEditingTools}
|
||||
*/
|
||||
|
@ -86,6 +86,7 @@ class EditableFormField extends DataObject
|
||||
"ExtraClass" => "Text", // from CustomSettings
|
||||
"RightTitle" => "Varchar(255)", // from CustomSettings
|
||||
"ShowOnLoad" => "Boolean(1)", // from CustomSettings
|
||||
"ShowInSummary" => "Boolean",
|
||||
);
|
||||
|
||||
private static $defaults = array(
|
||||
@ -160,6 +161,7 @@ class EditableFormField extends DataObject
|
||||
_t('EditableFormField.TYPE', 'Type'),
|
||||
$this->i18n_singular_name()
|
||||
),
|
||||
CheckboxField::create('ShowInSummary', _t('EditableFormField.SHOWINSUMMARY', 'Show in summary gridfield')),
|
||||
LiteralField::create(
|
||||
'MergeField',
|
||||
_t(
|
||||
|
@ -50,6 +50,26 @@ class UserDefinedFormTest extends FunctionalTest
|
||||
$this->assertTrue($fields->dataFieldByName('OnCompleteMessage') != null);
|
||||
}
|
||||
|
||||
|
||||
public function testGetCMSFieldsShowInSummary()
|
||||
{
|
||||
$this->logInWithPermission('ADMIN');
|
||||
$form = $this->objFromFixture('UserDefinedForm', 'summary-rules-form');
|
||||
|
||||
$fields = $form->getCMSFields();
|
||||
|
||||
$this->assertInstanceOf('GridField', $fields->dataFieldByName('Submissions'));
|
||||
|
||||
$submissionsgrid = $fields->dataFieldByName('Submissions');
|
||||
$gridFieldDataColumns = $submissionsgrid->getConfig()->getComponentByType('GridFieldDataColumns');
|
||||
|
||||
$summaryFields = $gridFieldDataColumns->getDisplayFields($submissionsgrid);
|
||||
|
||||
$this->assertContains('SummaryShow', array_keys($summaryFields), 'Summary field not showing displayed field');
|
||||
$this->assertNotContains('SummaryHide', array_keys($summaryFields), 'Summary field showing displayed field');
|
||||
}
|
||||
|
||||
|
||||
public function testEmailRecipientPopup()
|
||||
{
|
||||
$this->logInWithPermission('ADMIN');
|
||||
|
@ -107,6 +107,16 @@ EditableTextField:
|
||||
Required: true
|
||||
CustomErrorMessage: 'This field is required'
|
||||
|
||||
summary-show:
|
||||
Name: SummaryShow
|
||||
Title: Summary Text Field
|
||||
ShowInSummary: true
|
||||
|
||||
summary-hide:
|
||||
Name: SummaryHide
|
||||
Title: Summary Text Field
|
||||
ShowInSummary: false
|
||||
|
||||
EditableDropdown:
|
||||
basic-dropdown:
|
||||
Name: basic-dropdown
|
||||
@ -250,7 +260,12 @@ UserDefinedForm:
|
||||
|
||||
custom-rules-form:
|
||||
Title: Custom Rules Form
|
||||
Fields: =>EditableFormStep.form4step1,=>EditableCheckbox.checkbox-2, =>EditableTextField.basic-text-2
|
||||
Fields: =>EditableCheckbox.checkbox-2, =>EditableTextField.basic-text-2
|
||||
|
||||
summary-rules-form:
|
||||
Title: Summary Fields Form
|
||||
Fields: =>EditableTextField.summary-show, =>EditableTextField.summary-hide
|
||||
|
||||
empty-form:
|
||||
Title: Empty Form
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user