jazzband / django-floppyforms

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

ClearableFileInput widget doesn't handle initial_text, input_text and clear_checkbox_label #169

Closed ghost closed 8 years ago

ghost commented 8 years ago

According to the docs you should be able to override the mentioned attributes, however setting them has no effect.

This is what I've done

class CustomClearableFileInput(floppy.ClearableFileInput):
    """Override template on ClearableFileInput.
    """
    clear_checkbox_label = 'Remove custom cover'

but the output shows the default text. As far as I can see ClearableFileInput doesn't actually use these attributes, despite the documentation saying:

The initial_text, input_text and clear_checkbox_label attributes are provided in the template context.

I've also tried:

custom_background = forms.ImageField(
        required=False,
        widget=forms.ClearableFileInput(
            attrs={
                'accept': ','.join(settings.ALLOWED_IMAGE_TYPES),
                'clear_checkbox_label': 'Remove custom cover'}
        ),
        validators=[image_format_validator]
    )
gregmuellegger commented 8 years ago

Hi, thanks for the report. I've added the labels as documented and released 1.6.2 that contains the fix.