Open mrpmorris opened 5 years ago
@mrpmorris thanks your issue report. The sender
parameter in the event handlers would be an instance of EditContext
which you could use to access the validation state. The event args could do with some improvement. For now, we'll park this in the backlog and wait for more community asks for this feature..
That's a bit elusive, and involves the evil typecast approach. It also means a cost of more CPU cycles.
The args update would be much better.
I'm also missing this feature. Would be very useful.
I could cast sender
as EditContext, but currently there is no IsValid
Property in EditContext. Only Validate()
would return the ValidationState. But this would cost additional Resources to Re-Validate. And would end up in an endless loop.
(ValidationChangedEvent->Validate->ValitationChangedEvent->...)
IsValid = EditContext.GetValidationMessages().Count() == 0;
Seems to work, but it's not elegant.
@BrownBot That only works if you have added any validation messages. But i will use it for now..
Working with forms is really handicapped by having no way to access the state of a context without re-validating which often can be super expensive. This needs to be a property on the EditContext
or ValidationStateChangedEventArgs
end of sept 2022, and this is still not fixed. I have a submit button outside the form that should be disabled if the form is invalid. The button is also in the parent component, so I have to raise an event.
It would be better to have the form state passed as bool in the ValidationStateChangedEventArgs. Now we have to resort on @BrownBot's suggestion using IsValid = EditContext.GetValidationMessages().Count() == 0;
.
Please add this small but valueable improvement!
Thanks for contacting us.
We're moving this issue to the .NET 8 Planning
milestone for future evaluation / consideration. We would like to keep this around to collect more feedback, which can help us with prioritizing this work. We will re-evaluate this issue, during our next planning meeting(s).
If we later determine, that the issue has no community involvement, or it's very rare and low-impact issue, we will close it - so that the team can focus on more important and high impact issues.
To learn more about what to expect next and how this issue will be handled you can read more about our triage process here.
It would also be nice to be able to programmatically submit an EditForm. With this it would be easier to submit a form from another component. OnValidSubmit is the only event to catch a form submit. That's fine, but if we want to trigger the submit from an other component than a submit button in the editform or a button elsewhere with the form attribute referring to the editform id, then it's not possible without javascript.
We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.
@SteveSandersonMS can you please fill in the summary comment from the https://github.com/dotnet/aspnetcore/blob/main/docs/HelpWantedProcess.md and turn this into a help wanted
issue? Thanks!
We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.
Is your feature request related to a problem? Please describe.
I'm trying to detect when a Blazor EditForm's valid state changes so I can enable/disable a Submit button.
Describe the solution you'd like
Add an IsValid Boolean property to ValidationStateChangedEventArgs, and also add a ValidationStateChanged event to EditForm.
Additional context
Add any other context or screenshots about the feature request here.