Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RichTextarea not displaying correctly in a Bootstrap modal #103

Open
gustavengstrom opened this issue Jan 10, 2024 · 0 comments
Open

RichTextarea not displaying correctly in a Bootstrap modal #103

gustavengstrom opened this issue Jan 10, 2024 · 0 comments

Comments

@gustavengstrom
Copy link

I have the following form.

forms.py

class PersonForm(forms.Form):
    name = fields.CharField()
    text = fields.CharField(widget=RichTextarea())

which is rendered using:

urls.py

    path(
        "test_form/",
        FormView.as_view(
            form_class=PersonForm,
            template_name="test_form/test_form.html",
            success_url="/test_form/",
        ),
    ),

test_form.html (modal code copied from: Bootstrap docs)

{% load static %}
{% load render_form from formsetify %}
<!DOCTYPE html>
<html dir="ltr" lang="{{ LANGUAGE_CODE|default:'en' }}">

<head>
	<meta charset="utf-8"/>
	<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=5.0"/>
	<title>Django-Formset Demo</title>
	<link href="{% static 'vendor/bootstrap/dist/css/bootstrap.min.css' %}" rel="stylesheet" type="text/css" media="screen">
	<script type="module" src="{% static 'formset/js/django-formset.js' %}"></script>
</head>

<body>
<!-- Modal -->
<div class="modal fade" id="exampleModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <h1 class="modal-title fs-5" id="exampleModalLabel">Modal title</h1>
        <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
      </div>
      <div class="modal-body">
        <django-formset endpoint="{{ request.path }}" csrf-token="{{ csrf_token }}">
          {% render_form form "bootstrap" field_classes="mb-4" form_classes="rounded-xl" %}
          <button type="button" df-click="submit -> proceed">Submit</button>
        </django-formset>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
        <button type="button" class="btn btn-primary">Save changes</button>
      </div>
    </div>
  </div>
</div>

<!-- Button trigger modal -->
<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#exampleModal">
  Launch demo modal
</button>
</body>
<script src="{% static 'vendor/bootstrap/dist/js/bootstrap.min.js' %}"></script>
</html>

Which results in:
Screenshot 2024-01-10 at 13 00 06

Hence the Charfield renders correctly but not the RichTextarea...

p.s. Outside the model everything renders correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant