jazzband / django-floppyforms

Full control of form rendering in the templates.
http://django-floppyforms.readthedocs.org/
Other
837 stars 148 forks source link

the image_thumbnail.html example causes an error when image exist #199

Open michaelhjulskov opened 6 years ago

michaelhjulskov commented 6 years ago

Hi

Thanks for sharing I have a little issue regarding the image_thumbnail.html example. Issue is, that if an image already is saved and imagefield is required, if i render the form and do not select a new image, my browser will tell me that i need to pick a file. I tried to fix it this way, but it did not solve my issue:

old:

{# image_thumbnail.html #}
....some lines taken ot....
<input type="{{ type }}" name="{{ name }}"{% if required %} required{% endif %}{% include "floppyforms/attrs.html" %}>

new:

{# image_thumbnail.html #}
....some lines taken ot....
<input type="{{ type }}" name="{{ name }}"{% if required and not value.url %} required{% endif %}{% include "floppyforms/attrs.html" %}>

How to fix it? :)

michaelhjulskov commented 6 years ago

a quick test shows that issue dissapear when i remove this: {% if required %} required{% endif %}{% include "floppyforms/attrs.html" %}

But that isnt a solution obviously.

Hope for someone to help me :) Thanks

michaelhjulskov commented 6 years ago

This must be an issue that needs to be fixed! If there already is an image, you dont need to require a new image. Logically!

michaelhjulskov commented 6 years ago

This hack solves my issue.