neos-bot / flow-development-collection

The unified repository containing the Flow core packages, used for Flow development.
https://flow.neos.io/
MIT License
0 stars 0 forks source link

Provide a hint when a form with an upload field does not have enctype set correctly #24

Open neos-bot opened 9 years ago

neos-bot commented 9 years ago

Jira issue originally created by user @albe:

It would be nice if Fluid would inform the developer that he forgot to add the "enctype" attribute on the form when he is using an upload field, where enctype "multipart/form-data" is required.

Currently, the file upload will then just silently fail.

Jira-URL: https://jira.neos.io/browse/FLOW-176

neos-bot commented 9 years ago

Comment created by @bwaidelich:

IMO that's rather an issue of HTML/HTTP, but we could solve it theoretically by doing s.th. like

$this->viewHelperVariableContainer->add('TYPO3\Fluid\ViewHelpers\FormViewHelper', 'attributes', $this->tag->getAttributes());

in the FormViewHelper and then check that in the upload ViewHelper.. But I'm not sure if its worth the effort (and the additional coupling) TBH

neos-bot commented 9 years ago

Comment created by @albe:

Maybe it's enough if just the enctype is stored in the variableContainer, but you're right it adds coupling and is actually a problem of HTML/HTTP. It's just that we were sitting with two people for around half an hour searching why the upload did not do anything. Plus I remember I had that same problem when I first started with extbase.

It's really not a must-have, but it would just be so comfortable to get a hint on what is wrong with your upload.

neos-bot commented 9 years ago

Comment created by @albe:

Another idea to lessen the coupling, so the UploadVH does not have to know about all of the forms attributes: In FormViewHelper add $this->viewHelperVariableContainer->add('TYPO3\Fluid\ViewHelpers\FormViewHelper', 'required-enctype', '');

Then in UploadViewHelper update that variable to contain "multipart/form-data" and then when FormViewHelper finishes rendering, check that if "required-enctype" is non-empty and does not match the currently set enctype, throw an exception.

What do you think?

neos-bot commented 9 years ago

Comment created by @bwaidelich:

[~aberl] I like that idea and it would indeed make this simpler. I pushed a first WIP: http://review.typo3.org/40677 feel free to take over ;)

neos-bot commented 8 years ago

Comment created by @bwaidelich:

Sorry, I won't be able to take care of this right now. But a PR implementing it similar to https://review.typo3.org/40677 should work