16
16
17
17
trait CreatesElements
18
18
{
19
+ /**
20
+ * Create a <label> element
21
+ *
22
+ * @param string $label
23
+ * @return \Galahad\Aire\Elements\Label
24
+ */
19
25
public function label (string $ label ) : Label
20
26
{
21
27
return (new Label ($ this ->aire ))->text ($ label );
22
28
}
23
29
30
+ /**
31
+ * Create a <button> element
32
+ *
33
+ * @param string|null $label
34
+ * @return \Galahad\Aire\Elements\Button
35
+ */
24
36
public function button (string $ label = null ) : Button
25
37
{
26
38
$ button = new Button ($ this ->aire , $ this );
@@ -32,27 +44,53 @@ public function button(string $label = null) : Button
32
44
return $ button ;
33
45
}
34
46
47
+ /**
48
+ * Create a <button type="submit"> element
49
+ *
50
+ * @param string $label
51
+ * @return \Galahad\Aire\Elements\Button
52
+ */
35
53
public function submit (string $ label = 'Submit ' ) : Button
36
54
{
37
55
return $ this ->button ($ label )->type ('submit ' );
38
56
}
39
57
40
- public function input ($ name = null , $ label = null ) : Input
58
+ /**
59
+ * Create an <input>
60
+ *
61
+ * @param string|null $name
62
+ * @param string|\Illuminate\Contracts\Support\Htmlable|null $label
63
+ * @param string|null $type
64
+ * @return \Galahad\Aire\Elements\Input
65
+ */
66
+ public function input ($ name = null , $ label = null , $ type = null ) : Input
41
67
{
42
68
$ input = new Input ($ this ->aire , $ this );
43
69
44
70
if ($ name ) {
45
- $ input ->name ($ name );
71
+ $ input ->name (( string ) $ name );
46
72
}
47
73
48
74
if ($ label ) {
49
75
$ input ->label ($ label );
50
76
}
51
77
78
+ if ($ type ) {
79
+ $ input ->type ((string ) $ type );
80
+ }
81
+
52
82
return $ input ;
53
83
}
54
84
55
- public function select (array $ options , $ name = null , $ label = null ) : Select
85
+ /**
86
+ * Create a <select> element
87
+ *
88
+ * @param array|\Illuminate\Support\Collection|\Illuminate\Contracts\Support\Arrayable|\Illuminate\Contracts\Support\Jsonable|\JsonSerializable|\Traversable $options
89
+ * @param string|null $name
90
+ * @param string|\Illuminate\Contracts\Support\Htmlable|null $label
91
+ * @return \Galahad\Aire\Elements\Select
92
+ */
93
+ public function select ($ options , $ name = null , $ label = null ) : Select
56
94
{
57
95
$ select = new Select ($ this ->aire , $ options , $ this );
58
96
@@ -67,12 +105,19 @@ public function select(array $options, $name = null, $label = null) : Select
67
105
return $ select ;
68
106
}
69
107
108
+ /**
109
+ * Create a <textarea> element
110
+ *
111
+ * @param string|null $name
112
+ * @param string|\Illuminate\Contracts\Support\Htmlable|null $label
113
+ * @return \Galahad\Aire\Elements\Textarea
114
+ */
70
115
public function textArea ($ name = null , $ label = null ) : Textarea
71
116
{
72
117
$ textarea = new Textarea ($ this ->aire , $ this );
73
118
74
119
if ($ name ) {
75
- $ textarea ->name ($ name );
120
+ $ textarea ->name (( string ) $ name );
76
121
}
77
122
78
123
if ($ label ) {
@@ -82,12 +127,19 @@ public function textArea($name = null, $label = null) : Textarea
82
127
return $ textarea ;
83
128
}
84
129
130
+ /**
131
+ * Create a <textarea> element meant for WYSIWYG use (using JavaScript)
132
+ *
133
+ * @param string|null $name
134
+ * @param string|\Illuminate\Contracts\Support\Htmlable|null $label
135
+ * @return \Galahad\Aire\Elements\Textarea
136
+ */
85
137
public function wysiwyg ($ name = null , $ label = null ) : Textarea
86
138
{
87
139
$ textarea = new Wysiwyg ($ this ->aire , $ this );
88
140
89
141
if ($ name ) {
90
- $ textarea ->name ($ name );
142
+ $ textarea ->name (( string ) $ name );
91
143
}
92
144
93
145
if ($ label ) {
@@ -97,17 +149,30 @@ public function wysiwyg($name = null, $label = null) : Textarea
97
149
return $ textarea ;
98
150
}
99
151
100
- public function summary () : Summary
152
+ /**
153
+ * Create a summary view, which will show if there are errors
154
+ *
155
+ * @param bool $verbose
156
+ * @return \Galahad\Aire\Elements\Summary
157
+ */
158
+ public function summary (bool $ verbose = true ) : Summary
101
159
{
102
- return new Summary ($ this ->aire );
160
+ return ( new Summary ($ this ->aire , $ this ))-> verbose ( $ verbose );
103
161
}
104
162
163
+ /**
164
+ * Create a single <input type="checkbox"> element
165
+ *
166
+ * @param string|null $name
167
+ * @param string|\Illuminate\Contracts\Support\Htmlable|null $label
168
+ * @return \Galahad\Aire\Elements\Checkbox
169
+ */
105
170
public function checkbox ($ name = null , $ label = null ) : Checkbox
106
171
{
107
172
$ checkbox = new Checkbox ($ this ->aire , $ this );
108
173
109
174
if ($ name ) {
110
- $ checkbox ->name ($ name );
175
+ $ checkbox ->name (( string ) $ name );
111
176
}
112
177
113
178
if ($ label ) {
@@ -117,7 +182,15 @@ public function checkbox($name = null, $label = null) : Checkbox
117
182
return $ checkbox ;
118
183
}
119
184
120
- public function checkboxGroup (array $ options , $ name , $ label = null ) : CheckboxGroup
185
+ /**
186
+ * Create a group of <input type="checkbox"> elements
187
+ *
188
+ * @param array|\Illuminate\Support\Collection|\Illuminate\Contracts\Support\Arrayable|\Illuminate\Contracts\Support\Jsonable|\JsonSerializable|\Traversable $options
189
+ * @param string $name
190
+ * @param string|\Illuminate\Contracts\Support\Htmlable|null $label
191
+ * @return \Galahad\Aire\Elements\CheckboxGroup
192
+ */
193
+ public function checkboxGroup ($ options , $ name , $ label = null ) : CheckboxGroup
121
194
{
122
195
$ checkbox_group = new CheckboxGroup ($ this ->aire , $ options , $ this );
123
196
@@ -130,7 +203,15 @@ public function checkboxGroup(array $options, $name, $label = null) : CheckboxGr
130
203
return $ checkbox_group ;
131
204
}
132
205
133
- public function radioGroup (array $ options , $ name , $ label = null ) : RadioGroup
206
+ /**
207
+ * Create a group of <input type="radio"> elements
208
+ *
209
+ * @param array|\Illuminate\Support\Collection|\Illuminate\Contracts\Support\Arrayable|\Illuminate\Contracts\Support\Jsonable|\JsonSerializable|\Traversable $options
210
+ * @param string $name
211
+ * @param string|\Illuminate\Contracts\Support\Htmlable|null $label
212
+ * @return \Galahad\Aire\Elements\RadioGroup
213
+ */
214
+ public function radioGroup ($ options , $ name , $ label = null ) : RadioGroup
134
215
{
135
216
$ radio_group = new RadioGroup ($ this ->aire , $ options , $ this );
136
217
0 commit comments