Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions src/unfold/templates/unfold/widgets/textarea.html
Original file line number Diff line number Diff line change
@@ -1,7 +1 @@
<div class="relative">
<div class="border break-words font-medium invisible max-w-4xl px-3 py-2 text-sm" style="min-height: 64px">
{% if widget.value %}{{ widget.value|linebreaks }}{% endif %}
</div>

<textarea onInput="this.previousElementSibling.innerText = this.value + String.fromCharCode(10)" name="{{ widget.name }}"{% include "django/forms/widgets/attrs.html" %}>{% if widget.value %}{{ widget.value }}{% endif %}</textarea>
</div>
<textarea name="{{ widget.name }}"{% include "django/forms/widgets/attrs.html" %}>{% if widget.value %}{{ widget.value }}{% endif %}</textarea>
7 changes: 7 additions & 0 deletions src/unfold/templates/unfold/widgets/textarea_expandable.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<div class="relative">
<div class="border break-words font-medium invisible max-w-4xl px-3 py-2 text-sm" style="min-height: 64px">
{% if widget.value %}{{ widget.value|linebreaks }}{% endif %}
</div>

<textarea onInput="this.previousElementSibling.innerText = this.value + String.fromCharCode(10)" name="{{ widget.name }}"{% include "django/forms/widgets/attrs.html" %}>{% if widget.value %}{{ widget.value }}{% endif %}</textarea>
</div>
14 changes: 14 additions & 0 deletions src/unfold/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,20 @@ def __init__(
class UnfoldAdminTextareaWidget(AdminTextareaWidget):
template_name = "unfold/widgets/textarea.html"

def __init__(self, attrs: Optional[Dict[str, Any]] = None) -> None:
attrs = attrs or {}

super().__init__(
attrs={
"class": "vLargeTextField " + " ".join(TEXTAREA_CLASSES),
**(attrs or {}),
}
)


class UnfoldAdminExpandableTextareaWidget(AdminTextareaWidget):
template_name = "unfold/widgets/textarea.html"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This template_name is correct or unfold/widgets/textarea_expandable.html ?


def __init__(self, attrs: Optional[Dict[str, Any]] = None) -> None:
attrs = attrs or {}

Expand Down