@@ -51,6 +51,8 @@ protected function assemble(): void
51
51
['value ' => (string ) $ defaultCount ]
52
52
);
53
53
54
+ $ this ->addElement ('hidden ' , 'remove-position ' );
55
+
54
56
$ addCondition = $ this ->createElement (
55
57
'submitButton ' ,
56
58
'add-condition ' ,
@@ -76,7 +78,6 @@ protected function assemble(): void
76
78
for ($ i = 1 ; $ i <= $ conditionCount ; $ i ++) {
77
79
$ colName = 'column_ ' . $ i ;
78
80
$ opName = 'operator_ ' . $ i ;
79
- $ typeName = 'type_ ' . $ i ;
80
81
$ valName = 'val_ ' . $ i ;
81
82
82
83
$ col = $ this ->createElement (
@@ -126,18 +127,6 @@ protected function assemble(): void
126
127
]
127
128
);
128
129
129
- if (
130
- $ this ->getPopulatedValue ($ typeName ) !== 'incident_severity '
131
- && $ this ->getPopulatedValue ($ valName ) !== null
132
- ) {
133
- $ this ->clearPopulatedValue ($ typeName );
134
- $ this ->clearPopulatedValue ($ valName );
135
- }
136
-
137
- $ this ->addElement ('hidden ' , $ typeName , [
138
- 'value ' => 'incident_severity '
139
- ]);
140
-
141
130
break ;
142
131
case 'incident_age ' :
143
132
$ val = $ this ->createElement (
@@ -166,18 +155,6 @@ protected function assemble(): void
166
155
]
167
156
);
168
157
169
- if (
170
- $ this ->getPopulatedValue ($ typeName ) !== 'incident_age '
171
- && $ this ->getPopulatedValue ($ valName ) !== null
172
- ) {
173
- $ this ->clearPopulatedValue ($ typeName );
174
- $ this ->clearPopulatedValue ($ valName );
175
- }
176
-
177
- $ this ->addElement ('hidden ' , $ typeName , [
178
- 'value ' => 'incident_age '
179
- ]);
180
-
181
158
break ;
182
159
default :
183
160
$ val = $ this ->createElement ('text ' , $ valName , [
@@ -197,6 +174,7 @@ protected function assemble(): void
197
174
198
175
$ removePosition = (int ) $ this ->getValue ('remove ' );
199
176
if ($ removePosition ) {
177
+ $ this ->getElement ('remove-position ' )->setValue ($ removePosition );
200
178
unset($ this ->conditions [$ removePosition ]);
201
179
$ conditionCount -= 1 ;
202
180
if ($ conditionCount === 1 && ! $ this ->allowZeroConditions && $ removePosition === 2 ) {
@@ -207,7 +185,7 @@ protected function assemble(): void
207
185
$ this ->conditions [$ nextCount ]->conditionType ->setName ('column_ ' . $ n );
208
186
$ this ->conditions [$ nextCount ]->operator ->setName ('operator_ ' . $ n );
209
187
$ this ->conditions [$ nextCount ]->conditionVal ->setName ('val_ ' . $ n );
210
- if ($ conditionCount === 1 ) {
188
+ if ($ conditionCount === 1 && ! $ this -> allowZeroConditions ) {
211
189
$ this ->conditions [$ nextCount ]->removeButton = null ;
212
190
} elseif ($ this ->conditions [$ nextCount ]->removeButton ) {
213
191
$ this ->conditions [$ nextCount ]->removeButton ->setValue ((string ) $ n );
@@ -275,9 +253,17 @@ public function getCondition(): string
275
253
$ filter = Filter::any ();
276
254
/** @var int $count */
277
255
$ count = $ this ->getValue ('condition-count ' );
256
+ $ removePosition = $ this ->getValue ('remove-position ' );
257
+ if ($ removePosition ) {
258
+ $ count += 1 ;
259
+ }
278
260
279
261
if ($ count > 0 ) { // if count is 0, loop runs in reverse direction
280
262
foreach (range (1 , $ count ) as $ count ) {
263
+ if ($ count === (int ) $ removePosition ) {
264
+ continue ;
265
+ }
266
+
281
267
$ chosenType = $ this ->getValue ('column_ ' . $ count , 'placeholder ' );
282
268
283
269
$ filterStr = $ chosenType
0 commit comments