@@ -78,7 +78,8 @@ public function checkConditions(array $input): bool {
78
78
79
79
public function checkConditionSettings (array $ input ): bool {
80
80
if (!isset ($ input ['show_rule ' ])) {
81
- return false ;
81
+ // Inconsistency if show_rule set but no condition set
82
+ return !isset ($ input ['_conditions ' ]);
82
83
}
83
84
$ showRule = $ input ['show_rule ' ];
84
85
if ($ showRule == PluginFormcreatorCondition::SHOW_RULE_ALWAYS ) {
@@ -114,12 +115,23 @@ public function updateConditions($input) : bool {
114
115
$ itemtype = $ this ->getType ();
115
116
$ itemId = $ this ->getID ();
116
117
117
- // Delete all existing conditions for the question
118
- $ this ->deleteConditions ();
119
- if ($ this ->fields ['show_rule ' ] == PluginFormcreatorCondition::SHOW_RULE_ALWAYS ) {
120
- // No condition ? Exit now !
118
+ if (!isset ($ this ->input ['show_rule ' ]) && isset ($ this ->fields ['show_rule ' ]) && $ this ->fields ['show_rule ' ] == PluginFormcreatorCondition::SHOW_RULE_ALWAYS ) {
119
+ // rule not changed and is currently "always show"
120
+ $ this ->deleteConditions ();
121
+ return true ;
122
+ }
123
+ if (!isset ($ this ->input ['show_rule ' ]) && isset ($ this ->fields ['show_rule ' ]) && $ this ->fields ['show_rule ' ] != PluginFormcreatorCondition::SHOW_RULE_ALWAYS ) {
124
+ // Rule not changed and is not "always show"
121
125
return true ;
122
126
}
127
+ if (isset ($ this ->input ['show_rule ' ]) && $ this ->input ['show_rule ' ] == PluginFormcreatorCondition::SHOW_RULE_ALWAYS ) {
128
+ // rule changed to "always show"
129
+ $ this ->deleteConditions ();
130
+ return true ;
131
+ }
132
+
133
+ // Delete all existing conditions for the question
134
+ $ this ->deleteConditions ();
123
135
124
136
$ input = $ input ['_conditions ' ];
125
137
0 commit comments