|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace JeroenNoten\LaravelAdminLte\View\Components\Form; |
|
4
|
|
|
|
|
5
|
|
|
class InputSwitch extends InputGroupComponent |
|
6
|
|
|
{ |
|
7
|
|
|
/** |
|
8
|
|
|
* The Bootstrap Switch plugin configuration parameters. Array with |
|
9
|
|
|
* key => value pairs, where the key should be an existing configuration |
|
10
|
|
|
* property of the plugin. |
|
11
|
|
|
* |
|
12
|
|
|
* @var array |
|
13
|
|
|
*/ |
|
14
|
|
|
public $config; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* Create a new component instance. |
|
18
|
|
|
* Note this component requires the 'Bootstrap Switch' plugin. |
|
19
|
|
|
* |
|
20
|
|
|
* @return void |
|
21
|
|
|
*/ |
|
22
|
2 |
|
public function __construct( |
|
23
|
|
|
$name, $id = null, $label = null, $igroupSize = null, $labelClass = null, |
|
24
|
|
|
$fgroupClass = null, $igroupClass = null, $disableFeedback = null, |
|
25
|
|
|
$errorKey = null, $config = [] |
|
26
|
|
|
) { |
|
27
|
2 |
|
parent::__construct( |
|
28
|
2 |
|
$name, $id, $label, $igroupSize, $labelClass, $fgroupClass, |
|
29
|
|
|
$igroupClass, $disableFeedback, $errorKey |
|
30
|
|
|
); |
|
31
|
|
|
|
|
32
|
2 |
|
$this->config = is_array($config) ? $config : []; |
|
33
|
2 |
|
} |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* Make the class attribute for the "input-group" element. Note we overwrite |
|
37
|
|
|
* the method of the parent class. |
|
38
|
|
|
* |
|
39
|
|
|
* @return string |
|
40
|
|
|
*/ |
|
41
|
1 |
|
public function makeInputGroupClass() |
|
42
|
|
|
{ |
|
43
|
1 |
|
$classes = ['input-group']; |
|
44
|
|
|
|
|
45
|
1 |
|
if (isset($this->size) && in_array($this->size, ['sm', 'lg'])) { |
|
46
|
1 |
|
$classes[] = "input-group-{$this->size}"; |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
1 |
|
if ($this->isInvalid() && ! isset($this->disableFeedback)) { |
|
50
|
1 |
|
$classes[] = 'adminlte-invalid-iswgroup'; |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
1 |
|
if (isset($this->igroupClass)) { |
|
54
|
1 |
|
$classes[] = $this->igroupClass; |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
1 |
|
return implode(' ', $classes); |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* Make the class attribute for the input group item. |
|
62
|
|
|
* |
|
63
|
|
|
* @return string |
|
64
|
|
|
*/ |
|
65
|
1 |
|
public function makeItemClass() |
|
66
|
|
|
{ |
|
67
|
1 |
|
$classes = []; |
|
68
|
|
|
|
|
69
|
1 |
|
if ($this->isInvalid() && ! isset($this->disableFeedback)) { |
|
70
|
1 |
|
$classes[] = 'is-invalid'; |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
1 |
|
return implode(' ', $classes); |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
/** |
|
77
|
|
|
* Get the view / contents that represent the component. |
|
78
|
|
|
* |
|
79
|
|
|
* @return \Illuminate\View\View|string |
|
80
|
|
|
*/ |
|
81
|
1 |
|
public function render() |
|
82
|
|
|
{ |
|
83
|
1 |
|
return view('adminlte::components.form.input-switch'); |
|
84
|
|
|
} |
|
85
|
|
|
} |
|
86
|
|
|
|