-
Notifications
You must be signed in to change notification settings - Fork 820
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
FIX Handle validation errors in inline UploadFields #6091
FIX Handle validation errors in inline UploadFields #6091
Conversation
* Implemented redirect method to natively handle validation errors being sent back to the UploadField * Resolves silverstripe#6086
Interesting, I take it there's no way to make this work without adding the We shouldn't really be putting new APIs in to the 3.4 branch... |
@dhensby you guys would know better than me! This is the code that handled the form validation error and does something. I'm guessing that the UploadField might be a bit of a unique case in that it's run inside a frame. Looks like it's being treated as a controller, but doesn't share the same interface methods as a controller. Agree re: adding methods to that branch - shall I change to |
Hey @dhensby - I've changed to the |
@robbieaverill can I ask why is the method redirect() vs redirectBack()? I thought that this was the issue causing #6086. Even with the changed redirect option, it could fall back to redirectBack() in some cases. If you are implement the redirect() method then it would pay to follow the same method signature as Controller::redirect, which redirects to the given parameter. On a side note, this seems like another side effect of the framework having poorly defined roles for Controller vs RequestHandler. Form expects a Controller instance as parent, but there are MANY places we pass a RequestHandler instead, e.g. GridField. |
Hey @tractorcow, I used I haven't done any edge case testing on this, just thought I would propose it since it does fix the immediate problem (like a band aid I suppose). I know what you mean re the method signature, however it is not actually a redirect, so there is a semantic issue there which is more likely to be a problem in the way that class is architected or implemented. I don't want to go messing around with that of course. I didn't follow the method TL;DR: it's a quick fix for a bigger problem, one which I don't have time to look very far into I'm afraid. I'm happy for you guys to do whatever you see fit with this PR, but the issue does exist even with a standard FormField with a validation rule, e.g. Max length as provided out of the box. Cheers :-) |
I had another think about it... and I'm wondering if we don't move some logic up from Controller into RequestHandler: redirect(), redirectBack(), and Link(). That way we can explicitly allow Form::setController() to take a request handler (which we do in many cases), rather than require a controller. |
Yes please @tractorcow |
Closing - not sure this is the best way to fix the problem for now. |
I've proposed this in #6362 |
I'm happy to discuss this approach - not sure if it's the "best" way to do it - the iframe and duplicated assets scared me off a little ;)