Prevent default empty row being show in key-value field
Hi all
The key-value field is shown with a single empty row by default. Is there a way of preventing that? I don't want any rows shown until a user adds one.
Cheers
9 Replies
Set them as required so the user removes them?
Else, mutateBeforeSave and check for empty values and unset them
But that wouldn't work for the create form, would it? The KV field in this form is optional and rarely used so I want to make it as unobtrusive as possible. The UX feels confusing when there's a field there by default. It gives the impression that something needs to be entered. It feels much better when they only appear after "Add option" is clicked
So change default()
Tried that. ->default(null) and ->default('') don't work unfortunately.
Hmm might be a limitation of the key-value field. Just remove if if they are empty then in mutateBeforeSave
Yeah I think it might be a field limitation.
mutateFormDataBeforeSave
won't help because I'm trying to tweak this on the create form (before anything is saved). And the empty row always shows when the field is empty/null anyway.So mutateFormDataBeforeSave should help? it will show the data and you can unset it before the save process is completed.
mutateFormDataBeforeSave
is only available on EditRecord. I wanted to improve the UX of the create form.
But the main issue is the KV field displays an empty row when the attribute is empty/null, so mutating the data won't help.Sorry you want:
mutateFormDataUsing()
You will have all the data with: