--- /dev/null
+require(['WoltLabSuite/Core/Form/Builder/Field/Dependency/Empty'], function(EmptyFieldDependency) {
+ // dependency '{@$dependency->getId()}'
+ new EmptyFieldDependency(
+ '{@$dependency->getDependentNode()->getPrefixedId()}Container',
+ '{@$dependency->getField()->getPrefixedId()}'
+ );
+});
--- /dev/null
+require(['WoltLabSuite/Core/Form/Builder/Field/Dependency/Empty'], function(EmptyFieldDependency) {
+ // dependency '{@$dependency->getId()}'
+ new EmptyFieldDependency(
+ '{@$dependency->getDependentNode()->getPrefixedId()}Container',
+ '{@$dependency->getField()->getPrefixedId()}'
+ );
+});
--- /dev/null
+/**
+ * Form field dependency implementation that requires the value of a field to be empty.
+ *
+ * @author Matthias Schmidt
+ * @copyright 2001-2019 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @module WoltLabSuite/Core/Form/Builder/Field/Dependency/Empty
+ * @see module:WoltLabSuite/Core/Form/Builder/Field/Dependency/Abstract
+ * @since 5.2
+ */
+define(['./Abstract', 'Core'], function(Abstract, Core) {
+ "use strict";
+
+ /**
+ * @constructor
+ */
+ function Empty(dependentElementId, fieldId) {
+ this.init(dependentElementId, fieldId);
+ };
+ Core.inherit(Empty, Abstract, {
+ /**
+ * @see WoltLabSuite/Core/Form/Builder/Field/Dependency/Abstract#checkDependency
+ */
+ checkDependency: function() {
+ switch (this._field.tagName) {
+ case 'INPUT':
+ switch (this._field.type) {
+ case 'checkbox':
+ // TODO: check if working
+ return !this._field.checked;
+
+ case 'radio':
+ if (this._noField && this._noField.checked) {
+ return true;
+ }
+
+ return !this._field.checked;
+
+ default:
+ return this._field.value.trim().length === 0;
+ }
+
+ case 'SELECT':
+ // TODO: check if working for multiselect
+ return this._field.value.length === 0;
+
+ case 'TEXTAREA':
+ // TODO: check if working
+ return this._field.value.trim().length === 0;
+ }
+ }
+ });
+
+ return Empty;
+});
--- /dev/null
+<?php
+namespace wcf\system\form\builder\field\dependency;
+
+/**
+ * Represents a dependency that requires the value of a field is empty.
+ *
+ * @author Matthias Schmidt
+ * @copyright 2001-2019 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package WoltLabSuite\Core\System\Form\Builder\Field\Dependency
+ * @since 5.2
+ */
+class EmptyFormFieldDependency extends AbstractFormFieldDependency {
+ /**
+ * @inheritDoc
+ */
+ protected $templateName = '__emptyFormFieldDependency';
+
+ /**
+ * @inheritDoc
+ */
+ public function checkDependency() {
+ return empty($this->getField()->getValue());
+ }
+}