1

When submitting a form in Django I get: An invalid form control with name='text' is not focusable.

The reason it isn't working is because 'Chrome wants to focus on a control that is required but still empty so that it can pop up the message 'Please fill out this field'. However, if the control is hidden at the point that Chrome wants to pop up the message, that is at the time of form submission, Chrome can't focus on the control because it is hidden, therefore the form won't submit.' - An invalid form control with name='' is not focusable

But I am really not sure how to do this in TinyMCE or Django and was wondering if anyone knew.

HTML:

{% block content %}
    <div class="container">
        <div class="form-create">
            <form method="post" enctype="multipart/form-data">
                {% csrf_token %}
                {{ form|crispy }}
                <input type="submit" class="btn btn-success" value="Publish">
            </form>
        </div>
    </div>
{% endblock %}


{% block script %}
        tinyMCE.init({
            selector: '#id_text',
        });
{% endblock %}

Views:

class PostCreateView(LoginRequiredMixin, PostEdit, CreateView):
    fields = ['title', 'text', 'category', 'image', 'sub_description']

    def form_valid(self, form):
        form.instance.author = self.request.user
        return super().form_valid(form)
Max Loyd
  • 408
  • 6
  • 21

0 Answers0