-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Form Validation Status #2871
Form Validation Status #2871
Conversation
It seems to me like this overlaps with #2870 quite a bit, but perhaps with different end results. |
It does, sort of. This effectively just passes whether the submit button is disabled as a validation, while #2870 attempts to give the form its own validation abilities. |
Sorry, but I unfortunately don't think that's true. As they are implementing the same methods, it would cause some massive merge conflicts if one is merged before the other. |
Ah, yes, I suppose I was speaking a bit more theoretical. What I meant was that these changes should be almost entirely compatible (in concept) with those of #2870. I agree it would cause a merge conflict, but I don't think it would be very hard to resolve, as the conflicting functions are almost identical (other than a few lines). I'll doublecheck later today just to be sure. |
Mmm, now that I've checked, the main complication would be in |
Yes, I believe so too. More specifically I think |
There is a bit of logic from my Also, I should probably just make it public. |
We try never to expose new public API unless there is a clear use-case. So "just make it public" isn't something normally said ;). |
Fair enough, I figured that since the only other place that has it, has it public, this should probably be public too. |
Yes I see that too, and I realise this is not straight forward. Maybe it was the right thing to do. Apart from this point it looks like a great change and I am glad that @Cookie04DE is happy to build on it in the larger PR. What do you think @Jacalz ? |
Sounds good to me. I'm glad that everyone seems to be happy with landing this first. It might make the other PR easier to review as well given that a subset of it already will have landed by then. |
In some further testing, I discovered a bug where the error value didn't update properly because it was missing an initial But now it makes me wonder if there might be a better way of initializing this, perhaps adding an |
I'm not really sure what this has to do with custom widgets or Entry either - it is an internal detail of how form items are validated isn't it? |
It exists because Forms don't use the error of an item upon initialization (because we want to be nice to the end users on launch). To make sure that when an Entry that is invalid changes it's status we do something about it (i.e. enable submit), we set the error of the Entry to The issue with this behavior is that it only happens for an Entry, anything else (like a Form) needs to become invalid and then valid again (because Now that I'm less tired, I think the best solution to the problem is just to make |
Ah I see your point. What do you think @Jacalz ? |
Sorry for the late reply. I think it makes sense, but we need to be careful given that changing interfaces is a breaking change. |
So here's the question, should I add that change to this PR? Or should we make a separate one as an RFC to try and better alert anyone that may be caught by surprise from this change? |
Our contract is not to break things until 3.0 - so we can't just add the new method to the interface - it will break all custom validators. Looking for out of the box ideas as to how we can get this right I guess :) |
If you want to land this PR can it be done without the new method exposed? If this is to support embedding form in other form we can probably gloss over that for now... |
I'll admit I'm curious to see how many custom validators don't already have a
I'm not really sure there is, because any other container that holds validators would need to be able to do the same thing. So wither we have some not-simple logic to deal with this issue, or we just pre-set the validation error (which is nice and simple, but breaks an interface).
Yes it can, I've dealt with it in
This isn't just an issue for that use case. If someone puts anything between the Form and the Validator, it will cause a problem. |
Is there anything else I need to for this to get approved? |
Yes, I don't think my previous comment about the new external function was really addressed - as far as I can see it is not needed in this implementation, so should be left private for further discussion about how we manage the complications of the initial validation state.
The same is true for any combination of elements, as validation has to be passed up to the top level - anything that is not |
In summary of the above the issue of initial state for validation of a form should be separate and I think can be solved in a more elegant way (for example if the form was itself tracking if it had tested validation before assuming pass), so the additional external method may not be required when we solve it better. |
If you want I can make it private. I made it public simply because the other implementations I came across had it public as well. |
Perhaps you could leave an actual review on the code, that it's more clear what you want changed. |
Alrighty, lmk if you need any other changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, this looks good to me now. @Jacalz did you want a quick feedback as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a few notes on the code. Sorry for the late review.
Co-authored-by: Jacob <Jacalz@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was slightly incorrect in my last review. This is the right way to do it.
Co-authored-by: Jacob <Jacalz@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry. I found two things but I swear that this is approved when you have answered :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. Thanks. Sorry for all the back and forth. I have been very busy lately.
Btw, please don't force push when you don't have to. It has a habit of destroying the inline comments here on GitHub and generally makes reviewing harder.
Fair enough, I did it most recently because some commits from develop were accidentally merged into my branch and so I needed to drop them. |
Description:
Allows interacting with the validation status of a form
Checklist:
Where applicable: