You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a problem where I can't submit my form because my description textarea is required but hidden in my form. Any idea how I can solve this? I have no idea where style="display:none;" is coming from. Any idea?
class CustomFroalaEditor(FroalaEditor):
def __init__(self, *args, **kwargs):
super(CustomFroalaEditor, self).__init__(*args, **kwargs)
def render(self, name, value, attrs=None, renderer=None):
html = super(FroalaEditor, self).render(name, value, attrs)
return mark_safe(html)
class NewBlaForm(forms.ModelForm):
description = forms.CharField(widget=CustomFroalaEditor(attrs={'id': 'nb__description-editor'}))
class Meta:
model = Bla
fields = ('description')
The text was updated successfully, but these errors were encountered:
The form should still submit if you put content within the editor. The 'required' causes html5 validation which prevents submitting the form when it's blank. However, the browser is supposed to highlight the field, but it can't because it's hidden.
Here's a workaround:
fromfroala_editor.widgetsimportFroalaEditorasOriginalFroalaEditorclassFroalaEditor(OriginalFroalaEditor):
defuse_required_attribute(self, initial):
# textarea is hidden so HTML5 validation won't work properlyreturnFalse
tisdall
added a commit
to tisdall/django-froala-editor
that referenced
this issue
Nov 7, 2019
I have a problem where I can't submit my form because my description
textarea
isrequired
buthidden
in myform
. Any idea how I can solve this? I have no idea wherestyle="display:none;"
is coming from. Any idea?The text was updated successfully, but these errors were encountered: