Skip to content

Commit 9504bd8

Browse files
authored
feat: default simple textarea widget (#405)
1 parent 766098b commit 9504bd8

3 files changed

Lines changed: 22 additions & 7 deletions

File tree

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1 @@
1-
<div class="relative">
2-
<div class="border break-words font-medium invisible max-w-4xl px-3 py-2 text-sm" style="min-height: 64px">
3-
{% if widget.value %}{{ widget.value|linebreaks }}{% endif %}
4-
</div>
5-
6-
<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>
7-
</div>
1+
<textarea name="{{ widget.name }}"{% include "django/forms/widgets/attrs.html" %}>{% if widget.value %}{{ widget.value }}{% endif %}</textarea>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<div class="relative">
2+
<div class="border break-words font-medium invisible max-w-4xl px-3 py-2 text-sm" style="min-height: 64px">
3+
{% if widget.value %}{{ widget.value|linebreaks }}{% endif %}
4+
</div>
5+
6+
<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>
7+
</div>

src/unfold/widgets.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,20 @@ def __init__(
358358
class UnfoldAdminTextareaWidget(AdminTextareaWidget):
359359
template_name = "unfold/widgets/textarea.html"
360360

361+
def __init__(self, attrs: Optional[Dict[str, Any]] = None) -> None:
362+
attrs = attrs or {}
363+
364+
super().__init__(
365+
attrs={
366+
"class": "vLargeTextField " + " ".join(TEXTAREA_CLASSES),
367+
**(attrs or {}),
368+
}
369+
)
370+
371+
372+
class UnfoldAdminExpandableTextareaWidget(AdminTextareaWidget):
373+
template_name = "unfold/widgets/textarea.html"
374+
361375
def __init__(self, attrs: Optional[Dict[str, Any]] = None) -> None:
362376
attrs = attrs or {}
363377

0 commit comments

Comments
 (0)