@@ -20,6 +20,7 @@ protected function getFieldMinValueWithName($minValue)
20
20
{
21
21
return is_null ($ minValue ) ? '' : sprintf (" 'min' => '%s', " , $ minValue );
22
22
}
23
+
23
24
/**
24
25
* Gets the maxValue attribute.
25
26
*
@@ -31,6 +32,7 @@ protected function getFieldMaxValueWithName($maxValue)
31
32
{
32
33
return is_null ($ maxValue ) ? '' : sprintf (" 'max' => '%s', " , $ maxValue );
33
34
}
35
+
34
36
/**
35
37
* Get the minLength attribute.
36
38
*
@@ -42,6 +44,7 @@ protected function getFieldMinLengthName($minLength)
42
44
{
43
45
return empty ($ minLength ) ? '' : sprintf (" 'minlength' => '%s', " , $ minLength );
44
46
}
47
+
45
48
/**
46
49
* Gets the maxLength attribute.
47
50
*
@@ -53,6 +56,7 @@ protected function getFieldMaxLengthName($maxLength)
53
56
{
54
57
return empty ($ maxLength ) ? '' : sprintf (" 'maxlength' => '%s', " , $ maxLength );
55
58
}
59
+
56
60
/**
57
61
* Gets the required attribute.
58
62
*
@@ -64,6 +68,7 @@ protected function getFieldRequired($required)
64
68
{
65
69
return $ required ? sprintf (" 'required' => %s, " , ($ required ? 'true ' : 'false ' )) : '' ;
66
70
}
71
+
67
72
/**
68
73
* Get the placeholder attribute.
69
74
*
@@ -75,6 +80,7 @@ protected function getFieldPlaceHolder(Label $placeholder = null)
75
80
{
76
81
return is_null ($ placeholder ) ? '' : sprintf (" 'placeholder' => %s, " , $ this ->getTitle ($ placeholder ));
77
82
}
83
+
78
84
/**
79
85
* Get the placeholder attribute for a menu.
80
86
*
@@ -87,6 +93,7 @@ protected function getFieldPlaceHolderForMenu(Label $placeholder = null, $name =
87
93
{
88
94
return $ this ->getFieldPlaceHolder ($ placeholder );
89
95
}
96
+
90
97
/**
91
98
* Get the multiple attribute.
92
99
*
@@ -98,8 +105,9 @@ protected function getFieldMultiple($isMulti)
98
105
{
99
106
return $ isMulti ? "'multiple' => 'multiple', " : '' ;
100
107
}
108
+
101
109
/**
102
- * It gets converts an array to a stringbase array for the views.
110
+ * It gets converts an array to a string based array for the views.
103
111
*
104
112
* @param CrestApps\CodeGenerator\Models\Field $field
105
113
*
@@ -113,6 +121,7 @@ protected function getFieldItems(Field $field)
113
121
$ labels = $ field ->getOptionsByLang ();
114
122
return sprintf ('[%s] ' , implode (', ' . PHP_EOL , $ this ->getKeyValueStringsFromLabels ($ labels )));
115
123
}
124
+
116
125
/**
117
126
* Gets a plain title from a giving label.
118
127
*
@@ -125,6 +134,7 @@ protected function getPlainTitle(Label $label, $raw = false)
125
134
{
126
135
return sprintf (!$ raw ? "'%s' " : "%s " , $ label ->text );
127
136
}
137
+
128
138
/**
129
139
* Gets the fields value
130
140
*
@@ -142,6 +152,7 @@ protected function getFieldValue($value, $name)
142
152
}
143
153
return 'null ' ;
144
154
}
155
+
145
156
/**
146
157
* Gets checked item attribute.
147
158
*
@@ -159,6 +170,7 @@ protected function getCheckedItem($value, $name, $defaultValue)
159
170
$ value
160
171
);
161
172
}
173
+
162
174
/**
163
175
* Gets selected value attribute.
164
176
*
@@ -186,6 +198,7 @@ protected function getMultipleCheckedItem($value, $name, $defaultValue)
186
198
{
187
199
return sprintf (" (%s ? true : null) " , $ this ->getMultipleRawOptionValue ($ name , $ value , $ defaultValue ));
188
200
}
201
+
189
202
/**
190
203
* Gets a raw value for a giving field's name.
191
204
*
@@ -201,6 +214,7 @@ protected function getRawOptionValue($name, $value)
201
214
$ accessor = $ this ->getDefaultValueAccessor ($ modelVariable , $ name , $ valueString );
202
215
return sprintf ("old('%s', %s) " , $ name , $ accessor );
203
216
}
217
+
204
218
/**
205
219
* Gets a raw value for a giving field's name.
206
220
*
@@ -223,8 +237,10 @@ protected function getMultipleRawOptionValue($name, $value, $defaultValue)
223
237
$ defaultValueString = sprintf ('[%s] ' , $ joinedValues );
224
238
}
225
239
$ accessor = $ this ->getDefaultValueAccessor ($ modelVariable , $ name , $ defaultValueString );
226
- return sprintf ("in_array(%s, old('%s', %s)) " , $ valueString , $ name , $ accessor );
240
+
241
+ return sprintf ("in_array(%s, old('%s', %s) ?: []) " , $ valueString , $ name , $ accessor );
227
242
}
243
+
228
244
/**
229
245
* Gets the best value accessor for the view
230
246
*
@@ -245,6 +261,7 @@ protected function getDefaultValueAccessor($modelVariable, $property, $value)
245
261
}
246
262
return sprintf ("isset( \$%s->%s) ? \$%s->%s : %s " , $ modelVariable , $ property , $ modelVariable , $ property , $ value );
247
263
}
264
+
248
265
/**
249
266
* Gets selected value attribute.
250
267
*
@@ -258,6 +275,7 @@ protected function getMultipleSelectedValue($name, $valueAccessor, $defaultValue
258
275
{
259
276
return sprintf (" (%s ? true : null) " , $ name );
260
277
}
278
+
261
279
/**
262
280
* Gets the html steps attribute.
263
281
*
@@ -269,6 +287,7 @@ protected function getStepsValue($value)
269
287
{
270
288
return ($ value ) > 0 ? "'step' => \"any \", " : '' ;
271
289
}
290
+
272
291
/**
273
292
* Gets an instance of ViewLabelsGenerator
274
293
*
0 commit comments