@@ -2,46 +2,55 @@ module.exports = {
2
2
extend : '@apostrophecms/form-base-field-widget' ,
3
3
options : {
4
4
label : 'aposForm:select' ,
5
- icon : 'form-select-icon'
5
+ icon : 'form-select-icon' ,
6
+ allowMultiple : false
6
7
} ,
7
- fields : {
8
- add : {
9
- choices : {
10
- label : 'aposForm:selectChoice' ,
11
- type : 'array' ,
12
- titleField : 'label' ,
13
- required : true ,
14
- fields : {
15
- add : {
16
- label : {
17
- type : 'string' ,
18
- required : true ,
19
- label : 'aposForm:checkboxChoicesLabel' ,
20
- help : 'aposForm:checkboxChoicesLabelHelp'
21
- } ,
22
- value : {
23
- type : 'string' ,
24
- label : 'aposForm:checkboxChoicesValue' ,
25
- help : 'aposForm:checkboxChoicesValueHelp'
26
- }
8
+ fields ( self ) {
9
+ const optionalFields = self . options . allowMultiple
10
+ ? {
11
+ allowMultiple : {
12
+ label : 'aposForm:selectAllowMultiple' ,
13
+ type : 'boolean' ,
14
+ def : false
15
+ } ,
16
+ size : {
17
+ label : 'aposForm:selectSize' ,
18
+ type : 'integer' ,
19
+ def : 0 ,
20
+ min : 0 ,
21
+ if : {
22
+ allowMultiple : true
27
23
}
28
24
}
29
- } ,
30
- allowMultiple : {
31
- label : 'aposForm:selectAllowMultiple' ,
32
- type : 'boolean' ,
33
- def : false
34
- } ,
35
- size : {
36
- label : 'aposForm:selectSize' ,
37
- type : 'integer' ,
38
- def : 0 ,
39
- min : 0 ,
40
- if : {
41
- allowMultiple : true
42
- }
43
25
}
44
- }
26
+ : { } ;
27
+
28
+ return {
29
+ add : {
30
+ choices : {
31
+ label : 'aposForm:selectChoice' ,
32
+ type : 'array' ,
33
+ titleField : 'label' ,
34
+ required : true ,
35
+ fields : {
36
+ add : {
37
+ label : {
38
+ type : 'string' ,
39
+ required : true ,
40
+ label : 'aposForm:checkboxChoicesLabel' ,
41
+ help : 'aposForm:checkboxChoicesLabelHelp'
42
+ } ,
43
+ value : {
44
+ type : 'string' ,
45
+ label : 'aposForm:checkboxChoicesValue' ,
46
+ help : 'aposForm:checkboxChoicesValueHelp'
47
+ }
48
+ }
49
+ }
50
+ } ,
51
+ ...optionalFields
52
+ }
53
+ } ;
45
54
} ,
46
55
methods ( self ) {
47
56
return {
@@ -60,7 +69,7 @@ module.exports = {
60
69
req ,
61
70
{
62
71
...widget ,
63
- allowMultiple : widget . allowMultiple ?? false ,
72
+ allowMultiple : ( self . options . allowMultiple && widget . allowMultiple ) ?? false ,
64
73
size : widget . size ?? 0
65
74
} ,
66
75
options ,
0 commit comments