Blazored / AutoSaveEditForm

A replacement for the default EditForm component which will auto save a form until it is successfully submitted

Home Page:https://blazored.github.io/AutoSaveEditForm/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Feature Request] Expose Save method

Kim-SSi opened this issue · comments

Is your feature request related to a problem? Please describe.
Please expose the save method.

Additional context
The ability to save the form from another piece of code. Mainly complex auto complete and dynamically adding fields in the form from outside the form.

What I am using:

private async void SaveToStorage(object sender, FieldChangedEventArgs args)
{
	await SaveToStorage();
}

public async Task SaveToStorage()
{
	var model = Model ?? _fixedEditContext.Model;
	var serializedData = JsonSerializer.Serialize(model);
	await _jsRuntime.InvokeVoidAsync($"{GetSelectedStorageType()}.setItem", Id, serializedData);
}

I can create a PR if you would like.

Hi @Kim-SSi,

Could you help me understand the use case? Any change to a field in the model should trigger the autosave. Why's this not enough?

I will try to create a basic reproducer that demonstrates what I am doing.

I am adding to (or initializing) a List that is used in a foreach loop in the component.
When I checked the localstorage it was missing the new item.

I was trying to create a reproducer but it is now working.
I tried the latest netcoreapp3.1 and net5.0 - it worked.
Closing until I can create a reproducer of the issue.
Thanks for your help and sorry for the time this has taken.