@@ -288,6 +288,20 @@ public function rawSearchOptions() {
288
288
'massiveaction ' => true
289
289
];
290
290
291
+ $ tab [] = [
292
+ 'id ' => '35 ' ,
293
+ 'table ' => $ this ::getTable (),
294
+ 'field ' => 'is_default ' ,
295
+ 'datatype ' => 'specific ' ,
296
+ 'searchtype ' => [
297
+ '0 ' => 'equals ' ,
298
+ '1 ' => 'notequals '
299
+ ],
300
+ 'name ' => __ ('Default form ' , 'formcreator ' ),
301
+ 'searchtype ' => ['equals ' ],
302
+ 'massiveaction ' => true
303
+ ];
304
+
291
305
return $ tab ;
292
306
}
293
307
@@ -321,6 +335,17 @@ public static function getSpecificValueToSelect($field, $name = '', $values = ''
321
335
]);
322
336
break ;
323
337
338
+ case 'is_default ' :
339
+ return Dropdown::showFromArray ($ name , [
340
+ '0 ' => __ ('Not default form ' ),
341
+ '1 ' => __ ('Default form ' ),
342
+ ], [
343
+ 'value ' => $ values [$ field ],
344
+ 'display_emptychoice ' => false ,
345
+ 'display ' => false
346
+ ]);
347
+ break ;
348
+
324
349
case 'access_rights ' :
325
350
return Dropdown::showFromArray (
326
351
$ name ,
@@ -382,6 +407,25 @@ public static function getSpecificValueToDisplay($field, $values, array $options
382
407
return $ output ;
383
408
break ;
384
409
410
+ case 'is_default ' :
411
+ if ($ values [$ field ] == 0 ) {
412
+ $ class = "plugin-formcreator-inactive " ;
413
+ $ title = __ ('Not default form ' , 'formcreator ' );
414
+ } else {
415
+ $ class = "plugin-formcreator-active " ;
416
+ $ title = __ ('Default form ' , 'formcreator ' );
417
+ }
418
+ if (isset ($ options ['raw_data ' ]['id ' ])) {
419
+ $ output = '<i class="fa fa-circle '
420
+ . $ class
421
+ . '" aria-hidden="true" title=" ' . $ title . '"></i> ' ;
422
+ $ output = '<div style="text-align: center" onclick="plugin_formcreator.toggleDefaultForm( ' . $ options ['raw_data ' ]['id ' ]. ')"> ' . $ output . '</div> ' ;
423
+ } else {
424
+ $ output = $ title ;
425
+ }
426
+ return $ output ;
427
+ break ;
428
+
385
429
case 'access_rights ' :
386
430
switch ($ values [$ field ]) {
387
431
case self ::ACCESS_PUBLIC :
@@ -1054,10 +1098,18 @@ public function post_updateItem($history = 1) {
1054
1098
public function prepareInputForUpdate ($ input ) {
1055
1099
if (isset ($ input ['toggle ' ])) {
1056
1100
// Enable / disable form
1057
- return [
1058
- 'id ' => $ input ['id ' ],
1059
- 'is_active ' => $ this ->fields ['is_active ' ] == '0 ' ? '1 ' : '0 ' ,
1060
- ];
1101
+ if ($ input ['toggle ' ] == 'active ' ) {
1102
+ return [
1103
+ 'id ' => $ input ['id ' ],
1104
+ 'is_active ' => $ this ->fields ['is_active ' ] == '0 ' ? '1 ' : '0 ' ,
1105
+ ];
1106
+ }
1107
+ if ($ input ['toggle ' ] == 'default ' ) {
1108
+ return [
1109
+ 'id ' => $ input ['id ' ],
1110
+ 'is_default ' => $ this ->fields ['is_default ' ] == '0 ' ? '1 ' : '0 ' ,
1111
+ ];
1112
+ }
1061
1113
}
1062
1114
1063
1115
if (isset ($ input ['usage_count ' ])) {
0 commit comments