question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Nesting dropzone in existing form?

See original GitHub issue

I have a form for posting blog entries. I want to be able to submit multiple fields at once. Instead of designating the class of the form as ‘dropzone’ is it possible to be able to have a dropzone div nested in my current form so one button will submit all my fields, including multiple image upload, at once? Something like this stackoverflow question, but with flask-dropzone. Thanx in advance for any assistance!

My form:

<!DOCTYPE HTML>
<form action="{{ url_for('add_post') }}" method="post" class="add-post" enctype="multipart/form-data">
   <dl>
      <dt>Post title:
      <dd><input type="text" size="30" name="title" spellcheck="true" required>
      <dt>Post date:
      <dd><input type="date" name="post_date" required>
      <dt>Post description(one sentence):
      <dd><textarea name="description" rows="3" cols="40" spellcheck="true" required></textarea>
      <dt>Post html file:
      <dd><input type="file" name="html_file" required>
      <dt>Post image(s) file:</dt>

      <!--Can something like this be done?-->
      <div class="dropzone" id="myDropzone">
         {{ dropzone.create(action=url_for('show_posts')) }}
      </div>

      <dd><input type="submit" value="Submit">
   </dl>
</form>

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:24 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
harry-wrightcommented, Sep 12, 2018

My take was similiar to @Permafacture

I was considering generating a random UUID.

The images would upload instantly to a ‘/temp/string:UUID’ folder using handle_images_uploads().

The form would submit with UUID to handle_form() and check if there were any images added to the folder.

If my understanding’s correct though - I don’t seem to be able to send the CSRF token twice. So it adds vulnerability to the app.

1reaction
Permafacturecommented, Aug 18, 2018

I’ve created a pull request addressing #3 and partially #2. #3 really just needed the example updated, using the csrf token, though if you are fine with using a real CSRF token in that example then I’d add hashing the token rather than using the token to make the path directly. Completing #2 would require an example of updating the init function with a callback. I might do that if we end up needing that functionality for our project.

ps. not sure how link the the PR. haven’t done this on github before

pps. iteritems doesn’t make a list but it does make a generator object, so it’s still constructing a new python object. It’s not free. items builds the list in C code which is really fast. Especially for dictionaries with only dozens of elements, it’s not clear to me which would be faster, and both would be so fast that doing anything with each element would dwarf the time it takes to make the list or generator. And network io would be orders of magnitude more. So, I disagree that iteritems improves performance here.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Nesting dropzone in existing form? · Issue #14 - GitHub
I have a form for posting blog entries. I want to be able to submit multiple fields at once. Instead of designating the...
Read more >
Integrating Dropzone.js into a html form with other form fields
The class of your form is "dropzone" and that is why the form becomes a dropzone. Only use the "dropzone" class on the...
Read more >
Building Complex Nested Drag and Drop User Interfaces With ...
In our drawing sample, every draggable item has a drop zone before and after it (via the light blue shading). Each drag source...
Read more >
Integrating Dropzone.js into existing HTML form with other ...
Integrating Dropzone.js into existing HTML form with other fields in laravel (2020) #Part-2.
Read more >
Adding drop zones to a component | Acquia Cohesion Docs
Within the Elements list, drag the Component drop zone onto your Component layout where you want the editor to be able to drop...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found