You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: adminforth/documentation/docs/tutorial/03-Customization/02-customFieldRendering.md
+61Lines changed: 61 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -230,6 +230,67 @@ Now you can use this component in the configuration of the resource:
230
230
}
231
231
```
232
232
233
+
### Custom inValidity inside of the custom create/edit components
234
+
235
+
Custom componets can emit `update:inValidity` event to parent to say that the field is invalid.
236
+
237
+
You can define this emit as:
238
+
239
+
```ts
240
+
constemit=defineEmits([
241
+
"update:value",
242
+
//diff-add
243
+
"update:inValidity"
244
+
]);
245
+
```
246
+
247
+
Every time when state in your component becomes invalid, you can emit this event with error message which will be shown in the UI to the user.
248
+
249
+
```ts
250
+
emit('update:inValidity', "The field has wrong value");
251
+
```
252
+
253
+
Every time when state in your component becomes valid, you can emit this event with `false`
254
+
255
+
```ts
256
+
emit('update:inValidity', false);
257
+
```
258
+
259
+
If component never emits `update:inValidity` event (includign case when you don't use it at all), the field is considered valid.
260
+
261
+
### Custom emptiness inside of the custom create/edit components
262
+
263
+
Custom componets can emit `update:emptiness` event to parent to say that the field is empty.
264
+
265
+
Emptiness is used to prevent user from saving form when `column.required` is true and field is empty.
266
+
267
+
When `column.required` is false emptiness is not checked.
268
+
269
+
You can define this emit as:
270
+
271
+
```ts
272
+
constemit=defineEmits([
273
+
"update:value",
274
+
//diff-add
275
+
"update:emptiness"
276
+
]);
277
+
```
278
+
279
+
Every time when state in your component becomes empty, you can emit this event with `true`
280
+
281
+
```ts
282
+
emit('update:emptiness', true);
283
+
```
284
+
285
+
Every time when state in your component becomes not empty, you can emit this event with `false`
286
+
287
+
```ts
288
+
emit('update:emptiness', false);
289
+
```
290
+
291
+
Emptiness emit has a higher priority than natural emptiness of the field. For example when actual value under column in record is empty but component emitted `false` for `update:emptiness` (in other words child component said it non-empty), the field is considered as Non-empty.
292
+
For another example, if companent is naturally updated some value in record but emited `true` (said that it is empty) the field is considered as empty and error in form will be shown to user.
0 commit comments