mirror of
https://github.com/silverstripe/silverstripe-userforms.git
synced 2024-10-22 17:05:42 +02:00
FIX Ensure all fields are available for updateCMSFields(). (#1089)
This commit is contained in:
parent
243598f880
commit
60cd3d0937
@ -33,14 +33,14 @@ class EditableCheckbox extends EditableFormField
|
|||||||
*/
|
*/
|
||||||
public function getCMSFields()
|
public function getCMSFields()
|
||||||
{
|
{
|
||||||
$fields = parent::getCMSFields();
|
$this->beforeUpdateCMSFields(function (FieldList $fields) {
|
||||||
|
$fields->replaceField('Default', CheckboxField::create(
|
||||||
|
"CheckedDefault",
|
||||||
|
_t('SilverStripe\\UserForms\\Model\\EditableFormField.CHECKEDBYDEFAULT', 'Checked by Default?')
|
||||||
|
));
|
||||||
|
});
|
||||||
|
|
||||||
$fields->replaceField('Default', CheckboxField::create(
|
return parent::getCMSFields();
|
||||||
"CheckedDefault",
|
|
||||||
_t('SilverStripe\\UserForms\\Model\\EditableFormField.CHECKEDBYDEFAULT', 'Checked by Default?')
|
|
||||||
));
|
|
||||||
|
|
||||||
return $fields;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFormField()
|
public function getFormField()
|
||||||
|
@ -5,6 +5,7 @@ namespace SilverStripe\UserForms\Model\EditableFormField;
|
|||||||
use SilverStripe\Core\Manifest\ModuleLoader;
|
use SilverStripe\Core\Manifest\ModuleLoader;
|
||||||
use SilverStripe\Forms\CheckboxField;
|
use SilverStripe\Forms\CheckboxField;
|
||||||
use SilverStripe\Forms\DropdownField;
|
use SilverStripe\Forms\DropdownField;
|
||||||
|
use SilverStripe\Forms\FieldList;
|
||||||
use SilverStripe\Forms\TextField;
|
use SilverStripe\Forms\TextField;
|
||||||
use SilverStripe\i18n\i18n;
|
use SilverStripe\i18n\i18n;
|
||||||
use SilverStripe\UserForms\Model\EditableCustomRule;
|
use SilverStripe\UserForms\Model\EditableCustomRule;
|
||||||
@ -35,28 +36,28 @@ class EditableCountryDropdownField extends EditableFormField
|
|||||||
*/
|
*/
|
||||||
public function getCMSFields()
|
public function getCMSFields()
|
||||||
{
|
{
|
||||||
$fields = parent::getCMSFields();
|
$this->beforeUpdateCMSFields(function (FieldList $fields) {
|
||||||
|
$fields->removeByName('Default');
|
||||||
|
$fields->addFieldToTab(
|
||||||
|
'Root.Main',
|
||||||
|
DropdownField::create('Default', _t(__CLASS__ . '.DEFAULT', 'Default value'))
|
||||||
|
->setSource(i18n::getData()->getCountries())
|
||||||
|
->setHasEmptyDefault(true)
|
||||||
|
->setEmptyString('---')
|
||||||
|
);
|
||||||
|
|
||||||
$fields->removeByName('Default');
|
$fields->addFieldToTab(
|
||||||
$fields->addFieldToTab(
|
'Root.Main',
|
||||||
'Root.Main',
|
CheckboxField::create('UseEmptyString', _t(__CLASS__ . '.USE_EMPTY_STRING', 'Set default empty string'))
|
||||||
DropdownField::create('Default', _t(__CLASS__ . '.DEFAULT', 'Default value'))
|
);
|
||||||
->setSource(i18n::getData()->getCountries())
|
|
||||||
->setHasEmptyDefault(true)
|
|
||||||
->setEmptyString('---')
|
|
||||||
);
|
|
||||||
|
|
||||||
$fields->addFieldToTab(
|
$fields->addFieldToTab(
|
||||||
'Root.Main',
|
'Root.Main',
|
||||||
CheckboxField::create('UseEmptyString', _t(__CLASS__ . '.USE_EMPTY_STRING', 'Set default empty string'))
|
TextField::create('EmptyString', _t(__CLASS__ . '.EMPTY_STRING', 'Empty String'))
|
||||||
);
|
);
|
||||||
|
});
|
||||||
|
|
||||||
$fields->addFieldToTab(
|
return parent::getCMSFields();
|
||||||
'Root.Main',
|
|
||||||
TextField::create('EmptyString', _t(__CLASS__ . '.EMPTY_STRING', 'Empty String'))
|
|
||||||
);
|
|
||||||
|
|
||||||
return $fields;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFormField()
|
public function getFormField()
|
||||||
|
@ -36,23 +36,23 @@ class EditableDropdown extends EditableMultipleOptionField
|
|||||||
*/
|
*/
|
||||||
public function getCMSFields()
|
public function getCMSFields()
|
||||||
{
|
{
|
||||||
$fields = parent::getCMSFields();
|
$this->beforeUpdateCMSFields(function (FieldList $fields) {
|
||||||
|
$fields->addFieldToTab(
|
||||||
|
'Root.Main',
|
||||||
|
CheckboxField::create('UseEmptyString')
|
||||||
|
->setTitle('Set default empty string')
|
||||||
|
);
|
||||||
|
|
||||||
$fields->addFieldToTab(
|
$fields->addFieldToTab(
|
||||||
'Root.Main',
|
'Root.Main',
|
||||||
CheckboxField::create('UseEmptyString')
|
TextField::create('EmptyString')
|
||||||
->setTitle('Set default empty string')
|
->setTitle('Empty String')
|
||||||
);
|
);
|
||||||
|
|
||||||
$fields->addFieldToTab(
|
$fields->removeByName('Default');
|
||||||
'Root.Main',
|
});
|
||||||
TextField::create('EmptyString')
|
|
||||||
->setTitle('Empty String')
|
|
||||||
);
|
|
||||||
|
|
||||||
$fields->removeByName('Default');
|
return parent::getCMSFields();
|
||||||
|
|
||||||
return $fields;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
namespace SilverStripe\UserForms\Model\EditableFormField;
|
namespace SilverStripe\UserForms\Model\EditableFormField;
|
||||||
|
|
||||||
use SilverStripe\Core\Convert;
|
use SilverStripe\Core\Convert;
|
||||||
|
use SilverStripe\Forms\FieldList;
|
||||||
use SilverStripe\Forms\LabelField;
|
use SilverStripe\Forms\LabelField;
|
||||||
use SilverStripe\UserForms\FormField\UserFormsGroupField;
|
use SilverStripe\UserForms\FormField\UserFormsGroupField;
|
||||||
use SilverStripe\UserForms\Model\EditableFormField;
|
use SilverStripe\UserForms\Model\EditableFormField;
|
||||||
@ -46,9 +47,11 @@ class EditableFieldGroup extends EditableFormField
|
|||||||
|
|
||||||
public function getCMSFields()
|
public function getCMSFields()
|
||||||
{
|
{
|
||||||
$fields = parent::getCMSFields();
|
$this->beforeUpdateCMSFields(function (FieldList $fields) {
|
||||||
$fields->removeByName(['MergeField', 'Default', 'Validation', 'DisplayRules']);
|
$fields->removeByName(['MergeField', 'Default', 'Validation', 'DisplayRules']);
|
||||||
return $fields;
|
});
|
||||||
|
|
||||||
|
return parent::getCMSFields();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCMSTitle()
|
public function getCMSTitle()
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace SilverStripe\UserForms\Model\EditableFormField;
|
namespace SilverStripe\UserForms\Model\EditableFormField;
|
||||||
|
|
||||||
|
use SilverStripe\Forms\FieldList;
|
||||||
use SilverStripe\Forms\HiddenField;
|
use SilverStripe\Forms\HiddenField;
|
||||||
use SilverStripe\Forms\LabelField;
|
use SilverStripe\Forms\LabelField;
|
||||||
use SilverStripe\Security\Group;
|
use SilverStripe\Security\Group;
|
||||||
@ -50,9 +51,11 @@ class EditableFieldGroupEnd extends EditableFormField
|
|||||||
|
|
||||||
public function getCMSFields()
|
public function getCMSFields()
|
||||||
{
|
{
|
||||||
$fields = parent::getCMSFields();
|
$this->beforeUpdateCMSFields(function (FieldList $fields) {
|
||||||
$fields->removeByName(['MergeField', 'Default', 'Validation', 'DisplayRules']);
|
$fields->removeByName(['MergeField', 'Default', 'Validation', 'DisplayRules']);
|
||||||
return $fields;
|
});
|
||||||
|
|
||||||
|
return parent::getCMSFields();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getInlineClassnameField($column, $fieldClasses)
|
public function getInlineClassnameField($column, $fieldClasses)
|
||||||
|
@ -141,42 +141,42 @@ class EditableFileField extends EditableFormField
|
|||||||
*/
|
*/
|
||||||
public function getCMSFields()
|
public function getCMSFields()
|
||||||
{
|
{
|
||||||
$fields = parent::getCMSFields();
|
$this->beforeUpdateCMSFields(function (FieldList $fields) {
|
||||||
|
$treeView = TreeDropdownField::create(
|
||||||
|
'FolderID',
|
||||||
|
_t(__CLASS__.'.SELECTUPLOADFOLDER', 'Select upload folder'),
|
||||||
|
Folder::class
|
||||||
|
);
|
||||||
|
$treeView->setDescription(static::getFolderPermissionString($this->Folder()));
|
||||||
|
$fields->addFieldToTab(
|
||||||
|
'Root.Main',
|
||||||
|
$treeView
|
||||||
|
);
|
||||||
|
|
||||||
$treeView = TreeDropdownField::create(
|
// Warn the user if the folder targeted by this field is not restricted
|
||||||
'FolderID',
|
if ($this->FolderID && !$this->Folder()->hasRestrictedAccess()) {
|
||||||
_t(__CLASS__.'.SELECTUPLOADFOLDER', 'Select upload folder'),
|
$fields->addFieldToTab("Root.Main", LiteralField::create(
|
||||||
Folder::class
|
'FileUploadWarning',
|
||||||
);
|
'<p class="alert alert-warning">' . _t(
|
||||||
$treeView->setDescription(static::getFolderPermissionString($this->Folder()));
|
'SilverStripe\\UserForms\\Model\\UserDefinedForm.UnrestrictedFileUploadWarning',
|
||||||
$fields->addFieldToTab(
|
'Access to the current upload folder "{path}" is not restricted. Uploaded files will be publicly accessible if the exact URL is known.',
|
||||||
'Root.Main',
|
['path' => Convert::raw2att($this->Folder()->Filename)]
|
||||||
$treeView
|
)
|
||||||
);
|
. '</p>'
|
||||||
|
), 'Type');
|
||||||
|
}
|
||||||
|
|
||||||
// Warn the user if the folder targeted by this field is not restricted
|
$fields->addFieldToTab(
|
||||||
if ($this->FolderID && !$this->Folder()->hasRestrictedAccess()) {
|
'Root.Main',
|
||||||
$fields->addFieldToTab("Root.Main", LiteralField::create(
|
NumericField::create('MaxFileSizeMB')
|
||||||
'FileUploadWarning',
|
->setTitle('Max File Size MB')
|
||||||
'<p class="alert alert-warning">' . _t(
|
->setDescription("Note: Maximum php allowed size is {$this->getPHPMaxFileSizeMB()} MB")
|
||||||
'SilverStripe\\UserForms\\Model\\UserDefinedForm.UnrestrictedFileUploadWarning',
|
);
|
||||||
'Access to the current upload folder "{path}" is not restricted. Uploaded files will be publicly accessible if the exact URL is known.',
|
|
||||||
['path' => Convert::raw2att($this->Folder()->Filename)]
|
|
||||||
)
|
|
||||||
. '</p>'
|
|
||||||
), 'Type');
|
|
||||||
}
|
|
||||||
|
|
||||||
$fields->addFieldToTab(
|
$fields->removeByName('Default');
|
||||||
'Root.Main',
|
});
|
||||||
NumericField::create('MaxFileSizeMB')
|
|
||||||
->setTitle('Max File Size MB')
|
|
||||||
->setDescription("Note: Maximum php allowed size is {$this->getPHPMaxFileSizeMB()} MB")
|
|
||||||
);
|
|
||||||
|
|
||||||
$fields->removeByName('Default');
|
return parent::getCMSFields();
|
||||||
|
|
||||||
return $fields;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -40,32 +40,32 @@ class EditableFormHeading extends EditableFormField
|
|||||||
*/
|
*/
|
||||||
public function getCMSFields()
|
public function getCMSFields()
|
||||||
{
|
{
|
||||||
$fields = parent::getCMSFields();
|
$this->beforeUpdateCMSFields(function (FieldList $fields) {
|
||||||
|
$fields->removeByName(['Default', 'Validation', 'RightTitle']);
|
||||||
|
|
||||||
$fields->removeByName(['Default', 'Validation', 'RightTitle']);
|
$levels = [
|
||||||
|
'1' => '1',
|
||||||
|
'2' => '2',
|
||||||
|
'3' => '3',
|
||||||
|
'4' => '4',
|
||||||
|
'5' => '5',
|
||||||
|
'6' => '6'
|
||||||
|
];
|
||||||
|
|
||||||
$levels = [
|
$fields->addFieldsToTab('Root.Main', [
|
||||||
'1' => '1',
|
DropdownField::create(
|
||||||
'2' => '2',
|
'Level',
|
||||||
'3' => '3',
|
_t(__CLASS__.'.LEVEL', 'Select Heading Level'),
|
||||||
'4' => '4',
|
$levels
|
||||||
'5' => '5',
|
),
|
||||||
'6' => '6'
|
CheckboxField::create(
|
||||||
];
|
'HideFromReports',
|
||||||
|
_t('SilverStripe\\UserForms\\Model\\EditableFormField\\EditableLiteralField.HIDEFROMREPORT', 'Hide from reports?')
|
||||||
|
)
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
$fields->addFieldsToTab('Root.Main', [
|
return parent::getCMSFields();
|
||||||
DropdownField::create(
|
|
||||||
'Level',
|
|
||||||
_t(__CLASS__.'.LEVEL', 'Select Heading Level'),
|
|
||||||
$levels
|
|
||||||
),
|
|
||||||
CheckboxField::create(
|
|
||||||
'HideFromReports',
|
|
||||||
_t('SilverStripe\\UserForms\\Model\\EditableFormField\\EditableLiteralField.HIDEFROMREPORT', 'Hide from reports?')
|
|
||||||
)
|
|
||||||
]);
|
|
||||||
|
|
||||||
return $fields;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFormField()
|
public function getFormField()
|
||||||
|
@ -34,11 +34,11 @@ class EditableFormStep extends EditableFormField
|
|||||||
*/
|
*/
|
||||||
public function getCMSFields()
|
public function getCMSFields()
|
||||||
{
|
{
|
||||||
$fields = parent::getCMSFields();
|
$this->beforeUpdateCMSFields(function (FieldList $fields) {
|
||||||
|
$fields->removeByName(['MergeField', 'Default', 'Validation', 'RightTitle']);
|
||||||
|
});
|
||||||
|
|
||||||
$fields->removeByName(['MergeField', 'Default', 'Validation', 'RightTitle']);
|
return parent::getCMSFields();
|
||||||
|
|
||||||
return $fields;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -118,25 +118,25 @@ class EditableLiteralField extends EditableFormField
|
|||||||
*/
|
*/
|
||||||
public function getCMSFields()
|
public function getCMSFields()
|
||||||
{
|
{
|
||||||
$fields = parent::getCMSFields();
|
$this->beforeUpdateCMSFields(function (FieldList $fields) {
|
||||||
|
$fields->removeByName(['Default', 'Validation', 'RightTitle']);
|
||||||
|
|
||||||
$fields->removeByName(['Default', 'Validation', 'RightTitle']);
|
$fields->addFieldsToTab('Root.Main', [
|
||||||
|
HTMLEditorField::create('Content', _t(__CLASS__.'.CONTENT', 'HTML'))
|
||||||
|
->setRows(4)
|
||||||
|
->setColumns(20),
|
||||||
|
CheckboxField::create(
|
||||||
|
'HideFromReports',
|
||||||
|
_t(__CLASS__.'.HIDEFROMREPORT', 'Hide from reports?')
|
||||||
|
),
|
||||||
|
CheckboxField::create(
|
||||||
|
'HideLabel',
|
||||||
|
_t(__CLASS__.'.HIDELABEL', "Hide 'Title' label on frontend?")
|
||||||
|
)
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
$fields->addFieldsToTab('Root.Main', [
|
return parent::getCMSFields();
|
||||||
HTMLEditorField::create('Content', _t(__CLASS__.'.CONTENT', 'HTML'))
|
|
||||||
->setRows(4)
|
|
||||||
->setColumns(20),
|
|
||||||
CheckboxField::create(
|
|
||||||
'HideFromReports',
|
|
||||||
_t(__CLASS__.'.HIDEFROMREPORT', 'Hide from reports?')
|
|
||||||
),
|
|
||||||
CheckboxField::create(
|
|
||||||
'HideLabel',
|
|
||||||
_t(__CLASS__.'.HIDELABEL', "Hide 'Title' label on frontend?")
|
|
||||||
)
|
|
||||||
]);
|
|
||||||
|
|
||||||
return $fields;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFormField()
|
public function getFormField()
|
||||||
|
@ -32,22 +32,22 @@ class EditableMemberListField extends EditableFormField
|
|||||||
*/
|
*/
|
||||||
public function getCMSFields()
|
public function getCMSFields()
|
||||||
{
|
{
|
||||||
$fields = parent::getCMSFields();
|
$this->beforeUpdateCMSFields(function (FieldList $fields) {
|
||||||
|
$fields->removeByName('Default');
|
||||||
|
$fields->removeByName('Validation');
|
||||||
|
|
||||||
$fields->removeByName('Default');
|
/** @skipUpgrade */
|
||||||
$fields->removeByName('Validation');
|
$fields->addFieldToTab(
|
||||||
|
'Root.Main',
|
||||||
|
DropdownField::create(
|
||||||
|
'GroupID',
|
||||||
|
_t('SilverStripe\\UserForms\\Model\\EditableFormField.GROUP', 'Group'),
|
||||||
|
Group::get()->map()
|
||||||
|
)->setEmptyString(' ')
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
/** @skipUpgrade */
|
return parent::getCMSFields();
|
||||||
$fields->addFieldToTab(
|
|
||||||
'Root.Main',
|
|
||||||
DropdownField::create(
|
|
||||||
'GroupID',
|
|
||||||
_t('SilverStripe\\UserForms\\Model\\EditableFormField.GROUP', 'Group'),
|
|
||||||
Group::get()->map()
|
|
||||||
)->setEmptyString(' ')
|
|
||||||
);
|
|
||||||
|
|
||||||
return $fields;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFormField()
|
public function getFormField()
|
||||||
|
@ -26,11 +26,11 @@ class EditableRadioField extends EditableMultipleOptionField
|
|||||||
*/
|
*/
|
||||||
public function getCMSFields()
|
public function getCMSFields()
|
||||||
{
|
{
|
||||||
$fields = parent::getCMSFields();
|
$this->beforeUpdateCMSFields(function (FieldList $fields) {
|
||||||
|
$fields->removeByName('Default');
|
||||||
|
});
|
||||||
|
|
||||||
$fields->removeByName('Default');
|
return parent::getCMSFields();
|
||||||
|
|
||||||
return $fields;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFormField()
|
public function getFormField()
|
||||||
|
Loading…
Reference in New Issue
Block a user