Skip to content
This repository was archived by the owner on Jan 5, 2018. It is now read-only.

Commit ee9cd3b

Browse files
esolitosBerdir
authored andcommitted
Issue #2650854 by acke, esolitos: ImmutableConfigException on "File settings" form
1 parent 037509b commit ee9cd3b

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

src/Form/FileSettingsForm.php

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@
55
*/
66

77
namespace Drupal\file_entity\Form;
8-
use Drupal\Core\Form\FormBase;
8+
9+
use Drupal\Core\Form\ConfigFormBase;
910
use Drupal\Core\Form\FormStateInterface;
1011

1112
/**
1213
* Class FileSettingsForm
1314
* @package Drupal\file_entity\Form
1415
*/
15-
class FileSettingsForm extends FormBase {
16+
class FileSettingsForm extends ConfigFormBase {
1617

1718
/**
1819
* Returns a unique string identifying the form.
@@ -24,6 +25,15 @@ public function getFormId() {
2425
return 'file_settings';
2526
}
2627

28+
/**
29+
* {@inheritdoc}
30+
*/
31+
protected function getEditableConfigNames() {
32+
return [
33+
'file_entity.settings',
34+
];
35+
}
36+
2737
/**
2838
* {@inheritdoc}
2939
*/
@@ -33,7 +43,7 @@ public function buildForm(array $form, FormStateInterface $form_state) {
3343
'#title' => t('Maximum upload size'),
3444
'#default_value' => \Drupal::config('file_entity.settings')->get('max_filesize'),
3545
'#description' => t('Enter a value like "512" (bytes), "80 KB" (kilobytes) or "50 MB" (megabytes) in order to restrict the allowed file size. If left empty the file sizes will be limited only by PHP\'s maximum post and file upload sizes (current max limit <strong>%limit</strong>).', array('%limit' => format_size(file_upload_max_size()))),
36-
'#element_validate' => '\Drupal\file\Plugin\Field\FieldType\FileItem::validateMaxFilesize',
46+
'#element_validate' => ['\Drupal\file\Plugin\Field\FieldType\FileItem::validateMaxFilesize'],
3747
'#size' => 10,
3848
);
3949

@@ -42,7 +52,7 @@ public function buildForm(array $form, FormStateInterface $form_state) {
4252
'#title' => t('Default allowed file extensions'),
4353
'#default_value' => \Drupal::config('file_entity.settings')->get('default_allowed_extensions'),
4454
'#description' => t('Separate extensions with a space or comma and do not include the leading dot.'),
45-
'#element_validate' => '\Drupal\file\Plugin\Field\FieldType\FileItem::validateExtensions',
55+
'#element_validate' => ['\Drupal\file\Plugin\Field\FieldType\FileItem::validateExtensions'],
4656
'#maxlength' => NULL,
4757
);
4858

0 commit comments

Comments
 (0)