File tree 3 files changed +40
-1
lines changed
3 files changed +40
-1
lines changed Original file line number Diff line number Diff line change @@ -36,6 +36,11 @@ public function getPublicValue()
36
36
return $ this ->getValue ();
37
37
}
38
38
39
+ public function getLabelValue ()
40
+ {
41
+ return $ this ->getPublicValue ();
42
+ }
43
+
39
44
public function getAdminJson ()
40
45
{
41
46
return $ this ->getValue ();
Original file line number Diff line number Diff line change @@ -29,6 +29,10 @@ public function getValue()
29
29
return [];
30
30
}
31
31
32
+ if (is_array ($ this ->value )){
33
+ return $ this ->value ;
34
+ }
35
+
32
36
return explode (', ' , $ this ->value );
33
37
}
34
38
@@ -50,6 +54,24 @@ public function getPublicValue()
50
54
return $ this ->getValue ();
51
55
}
52
56
57
+ public function getLabelValue (){
58
+ $ value = $ this ->getValue ();
59
+
60
+ $ result = [];
61
+ foreach ($ value as $ valueItem ){
62
+ $ found = null ;
63
+ foreach ($ this ->options as $ option ){
64
+ if ($ option ['value ' ] === $ valueItem ){
65
+ $ found = $ option ['label ' ];
66
+ }
67
+ }
68
+
69
+ $ result [] = $ found ?? $ valueItem ;
70
+ }
71
+
72
+ return implode (', ' , $ result );
73
+ }
74
+
53
75
public function getDatabaseValue ()
54
76
{
55
77
if (!$ this ->value ) {
Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ public function setOptions(array $options)
14
14
{
15
15
$ this ->options = $ options ;
16
16
}
17
-
17
+
18
18
public function getType ()
19
19
{
20
20
return FieldType::Select;
@@ -43,6 +43,18 @@ public function getPublicValue()
43
43
return $ this ->getValue ();
44
44
}
45
45
46
+ public function getLabelValue (){
47
+ $ valueItem = $ this ->getValue ();
48
+
49
+ foreach ($ this ->options as $ option ){
50
+ if ($ option ['value ' ] === $ valueItem ){
51
+ return $ option ['label ' ];
52
+ }
53
+ }
54
+
55
+ return $ valueItem ;
56
+ }
57
+
46
58
public function getAdminJson ()
47
59
{
48
60
return $ this ->getValue ();
You can’t perform that action at this time.
0 commit comments