Skip to content
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

Document adding file field to the FormBuilder by linking to tutorial #5284

Closed
unexceptable opened this issue May 8, 2019 · 9 comments
Closed

Comments

@unexceptable
Copy link
Contributor

It is fairly common when making forms to potentially request from someone that they upload a file, or an image. I feel like this is common enough that having it in base wagtail may be useful.

The only hard part would be that it would need you to select a collection to upload those files to.

We're working on making one currently based on the work by @lb- (https://posts-by.lb.ee/image-uploads-in-wagtail-forms-3121c9b35d27), and would be happy to work on upstreaming that if that is something that makes sense for Wagtail.

@zerolab
Copy link
Contributor

zerolab commented May 9, 2019

IMHO the collection issue is two-fold:

  1. end-users should not need to deal with it at all
  2. if configurability is needed, that should happen in the form configuration itself

I have seen quite a number of requests about it, so worth working it. But the final decision is for the core maintainers. I wager you could write a separate package and iterate on it until you are happy and then move to get it included in Wagtail.

If you go with the latter, may I suggest you tackle multi-field uploads as well (here is an example of something like this). That is, if you get the time/resources.

Thank you.

@unexceptable
Copy link
Contributor Author

@zerolab So far we are solving the collection problem by having it as an optionally blank field on the form page (which could also be done to the abstract one), and in the clean function, raising a validation error if a file field is used in the form, but no collection is set. This makes for reasonably clean and safe UX.

As for multi-file upload, that may be a little harder, but doable and could piggyback on the same work.

@lb-
Copy link
Member

lb- commented May 17, 2019

Hey, I personally think that adding this type of field to the default form builder model would not be helpful, it will be confusing for developers and potentially add code for a case that will only be used by some.

I think something like this would be best served by an extension/plugin/library that creates a kind of wagtail-upload-form that can be imported and used, it could work with the basics needed and allow developers do use it in a very similar way they currently use the form models.

The other thing to remember is the docs clearly state that the wagtail forms system is not meant to replace the full power and functionality of Django forms. At some point, you will end up re-building Django forms and all their 'power', but that is not helpful in the long run.

If there is something in the core models that could be helpful to achieve the above mentioned plugin, it might be worth looking at but for now I think this would be best closed.

I will leave open for further discussion.

@loicteixeira
Copy link
Member

It's been 4 months since the issue was left open for further discussion and it hasn't received any comment, therefore we will leave it at "it would be better served as a third party package", like for example springload/wagtail-django-recaptcha.

I'll rename the issue for tutorial mentionned above to be included on the Third-party tutorials page.

@loicteixeira loicteixeira changed the title Formbuilder to include file field_type by default Document adding file field to the FormBuilder by linking to tutorial Sep 29, 2019
@dwasyl
Copy link
Contributor

dwasyl commented Sep 29, 2019

@loicteixeira If there's an easy way to add it via an external plugin that's great. I remember when I first went down the road of needing a file to be submitted with a form, there were a number of barriers in the overall Wagtail codebase that prevented it. Seems like many of those have been dealt with.

That said, I think the more comprehensive the forms module is the better. Especially when it comes to attracting new users and making the system as easy to use as possible. But if no one wants to build the PR then it documentation of a tutorial works.

@a-mere-peasant
Copy link
Contributor

i would like to help with this , how can i start ?

@loicteixeira
Copy link
Member

Hi @a-mere-peasant. I'm glad to hear you're interesting of having a go at this issue. What needs to be done is adding a link to the Image Uploads in Wagtail Forms tutorial on the Third-party tutorials documetnation. Here is the corresponding source file. Good luck!

@dwasyl, thanks for your feedback. I believe the process should be a little bit easier now (e.g. step 4 of the linked tutorial isn't needed anymore, maybe @lb- would be able to update the tutorial accordingly?). The consensus seemed to be to leave it as a third-party plugin for now (which doesn't mean it cannot make it into wagtail core later) and hopefully springload/wagtail-django-recaptcha can give a glimpse of what needs to be done.

@lb-
Copy link
Member

lb- commented Oct 6, 2019

Thanks @loicteixeira - agree with all of the above.

I do have it on my radar to redo these, and a few other tutorials, hopefully I get the chance to do that in the coming months :)

@thibaudcolas
Copy link
Member

I see the link got added in #5604, so will close this now. I’ve also updated the link in the docs to the latest version of the tutorial from LB: https://dev.to/lb/image-uploads-in-wagtail-forms-39pl.

@thibaudcolas thibaudcolas added this to the 2.12 milestone Dec 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants