1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Hechoenlaravel\JarvisFoundation\Field\Select; |
4
|
|
|
|
5
|
|
|
use Styde\Html\Facades\Field; |
6
|
|
|
use Hechoenlaravel\JarvisFoundation\Field\FieldTypeInterface; |
7
|
|
|
use Hechoenlaravel\JarvisFoundation\Field\FieldTypeImplementationTrait; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* Class SelectFieldType |
11
|
|
|
* @package Hechoenlaravel\JarvisFoundation\Field\Text |
12
|
|
|
*/ |
13
|
|
|
class SelectFieldType implements FieldTypeInterface |
14
|
|
|
{ |
15
|
|
|
use FieldTypeImplementationTrait; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* @var |
19
|
|
|
*/ |
20
|
|
|
private $value; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* @var string |
24
|
|
|
*/ |
25
|
|
|
protected $columnType = "string"; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* The field type name |
29
|
|
|
* @var string |
30
|
|
|
*/ |
31
|
|
|
public $name = "Lista de selección"; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* The field slug for the instance |
35
|
|
|
* @var |
36
|
|
|
*/ |
37
|
|
|
public $fieldSlug; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* The field Name for the instance |
41
|
|
|
* @var |
42
|
|
|
*/ |
43
|
|
|
public $fieldName; |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* The field description for the instance |
47
|
|
|
* @var |
48
|
|
|
*/ |
49
|
|
|
public $fieldDescription; |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* The field Options for the Instance |
53
|
|
|
* @var |
54
|
|
|
*/ |
55
|
|
|
public $fieldOptions; |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* Validation rules for the field type |
59
|
|
|
* @var array |
60
|
|
|
*/ |
61
|
|
|
public $validationRules = ['']; |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* get the column type for this field type |
65
|
|
|
* @return string |
66
|
|
|
*/ |
67
|
|
|
public function getColumnType() |
68
|
|
|
{ |
69
|
|
|
return $this->columnType; |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* Set a value for this field; |
74
|
|
|
* @param $value |
75
|
|
|
*/ |
76
|
|
|
public function setValue($value) |
77
|
|
|
{ |
78
|
|
|
$this->value = $value; |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* get the value for the field |
84
|
|
|
* @return mixed |
85
|
|
|
*/ |
86
|
|
|
public function getValue() |
87
|
|
|
{ |
88
|
|
|
return $this->value; |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* return the form view |
93
|
|
|
* @return mixed |
94
|
|
|
*/ |
95
|
|
|
public function present() |
96
|
|
|
{ |
97
|
|
|
$options = []; |
98
|
|
|
foreach(unserialize($this->fieldOptions) as $o) |
99
|
|
|
{ |
100
|
|
|
$options[$o] = $o; |
101
|
|
|
} |
102
|
|
|
return Field::select($this->fieldSlug, $options , $this->value, ['label' => $this->fieldName, 'class' => 'select2']); |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
/** |
106
|
|
|
* Que the form for the options of the field type |
107
|
|
|
* @return mixed |
108
|
|
|
*/ |
109
|
|
|
public function getOptionsForm() |
110
|
|
|
{ |
111
|
|
|
return view('jarvisPlatform::field.types.select.optionsForm')->render(); |
|
|
|
|
112
|
|
|
} |
113
|
|
|
} |
114
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.