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

Closed
ghost opened this Issue Apr 1, 2016 · 1 comment

Projects

None yet

1 participant

@ghost
ghost commented Apr 1, 2016

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
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment