From: Matthias Schmidt Date: Sat, 10 Feb 2018 19:41:00 +0000 (+0100) Subject: Add form field to disable objects X-Git-Tag: 5.2.0_Alpha_1~812 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=5759f259befaf72e93701674f24114a7b40830fb;p=GitHub%2FWoltLab%2FWCF.git Add form field to disable objects See #2509 --- 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'); + } +}