From 5759f259befaf72e93701674f24114a7b40830fb Mon Sep 17 00:00:00 2001 From: Matthias Schmidt Date: Sat, 10 Feb 2018 20:41:00 +0100 Subject: [PATCH] Add form field to disable objects See #2509 --- .../DevtoolsFormBuilderTestForm.class.php | 3 ++- .../field/IsDisabledFormField.class.php | 25 +++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 wcfsetup/install/files/lib/system/form/builder/field/IsDisabledFormField.class.php diff --git a/wcfsetup/install/files/lib/acp/form/DevtoolsFormBuilderTestForm.class.php b/wcfsetup/install/files/lib/acp/form/DevtoolsFormBuilderTestForm.class.php index e4cda25906..1ae952dd10 100644 --- a/wcfsetup/install/files/lib/acp/form/DevtoolsFormBuilderTestForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/DevtoolsFormBuilderTestForm.class.php @@ -9,6 +9,7 @@ use wcf\system\form\builder\container\TabMenuFormContainer; use wcf\system\form\builder\field\data\CustomFormFieldDataProcessor; use wcf\system\form\builder\field\dependency\NonEmptyFormFieldDependency; use wcf\system\form\builder\field\dependency\ValueFormFieldDependency; +use wcf\system\form\builder\field\IsDisabledFormField; use wcf\system\form\builder\field\TitleFormField; use wcf\system\form\builder\field\validation\FormFieldValidationError; use wcf\system\form\builder\field\validation\FormFieldValidator; @@ -91,7 +92,7 @@ class DevtoolsFormBuilderTestForm extends AbstractForm { ->i18n() ->i18nRequired() ->required(), - BooleanFormField::create('isDisabled') + IsDisabledFormField::create() ->label('Foo is Disabled') ->description('If Foo is disabled, it is indeed disabled.') ->addValidator(new FormFieldValidator('notSelected', function(BooleanFormField $field) { diff --git a/wcfsetup/install/files/lib/system/form/builder/field/IsDisabledFormField.class.php b/wcfsetup/install/files/lib/system/form/builder/field/IsDisabledFormField.class.php new file mode 100644 index 0000000000..2568c25cb3 --- /dev/null +++ b/wcfsetup/install/files/lib/system/form/builder/field/IsDisabledFormField.class.php @@ -0,0 +1,25 @@ + + * @package WoltLabSuite\Core\System\Form\Builder\Field + * @since 3.2 + */ +class IsDisabledFormField extends BooleanFormField { + /** + * @inheritDoc + */ + public static function create(string $id = null): IFormNode { + if ($id !== null) { + throw new \InvalidArgumentException("This method does not expect any parameters. The id of form fields of this class are always 'isDisabled'."); + } + + return parent::create('isDisabled'); + } +} -- 2.20.1