Add textarea rendering

This commit is contained in:
László Károlyi 2024-11-24 22:11:00 +01:00
parent e9dc5a07ec
commit d231505686
Signed by: karolyi
GPG key ID: 2DCAF25E55735BFE
2 changed files with 37 additions and 0 deletions

View file

@ -126,6 +126,10 @@ _TEMPLATE_MAPPINGS = {
'template_name': (
'widgets/bootstrap5/floating/input-hidden.html.jinja'),
},
'Textarea': {
'template_name': (
'widgets/bootstrap5/floating/input-textarea.html.jinja'),
},
'CheckboxSelectMultiple': {
'template_name': (
'widgets/bootstrap5/floating/multiple-input.html.jinja'),

View file

@ -0,0 +1,33 @@
{% from 'widgets/bootstrap5/floating/attr-class.html.jinja' import attr_class with context %}
<div class="form-floating mb-3" data-ktools-field-type="{{ dash_case_convert(name=_k_boundfield.field.widget.__class__.__name__) }}">
<textarea name="{{ widget.name|e }}"
{%- if _k_boundfield.form.is_bound %}
{% if _k_boundfield.errors %}
{{- attr_class(widget, 'form-control is-invalid') -}}
{% elif _k_boundfield.mark_if_valid %}
{{- attr_class(widget, 'form-control is-valid') -}}
{% else %}
{{- attr_class(widget, 'form-control') -}}
{% endif %}
{% else %}
{{- attr_class(widget, 'form-control') -}}
{% endif %}
{% include 'widgets/bootstrap5/floating/attrs-wo-class.html.jinja' %}
placeholder="{{ _k_boundfield.label|e }}">
{%- if widget.value != None %}{{ widget.value|e }}{% endif %}
</textarea>
<label for="{{ widget.attrs.id }}">{{ _k_boundfield.label }}</label>
{% if _k_boundfield.form.is_bound and _k_boundfield.errors %}
<div id="{{ _k_boundfield.form.errorfeedback_prefix }}{{ widget.attrs.id }}" class="invalid-feedback">
{% for error in _k_boundfield.errors %}
<p class="mb-0">
<i class="bi bi-exclamation-octagon-fill"></i>
{{ error|e }}
</p>
{% endfor %}
</div>
{% endif %}
{% if _k_boundfield.help_text %}
<small class="text-muted">{{ _k_boundfield.help_text }}</small>
{% endif %}
</div>