Skip to content

Commit

Permalink
feat: form inputs with errors
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasvinclav committed Oct 30, 2022
1 parent d94f9b2 commit b4e4a23
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
__pycache__
venv
node_modules
dist/
dist/
2 changes: 1 addition & 1 deletion src/unfold/static/unfold/css/styles.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/unfold/templates/admin/edit_inline/tabular.html
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ <h2 class="bg-gray-100 font-semibold mb-6 px-4 py-3 rounded-md text-gray-900 tex
{{ field.field }}

{% if field.field.errors|length > 0 %}
<div class="mt-1 ext-sm text-red-600">
<div class="mt-1 text-red-600 text-sm">
{% for error in field.field.errors %}
{{ error }}
{% endfor %}
Expand Down
2 changes: 1 addition & 1 deletion src/unfold/templates/admin/includes/fieldset.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ <h2 class="bg-gray-100 font-semibold mb-6 px-4 py-3 rounded-md text-gray-900 tex

<div class="aligned border mb-8 rounded-md pt-3 px-3 shadow-sm">
{% for line in fieldset %}
<div class="block {% if line.fields|length_is:'1' and line.errors %} errors{% endif %}{% if not line.has_visible_field %} hidden{% endif %}{% for field in line %}{% if field.field.name %} field-{{ field.field.name }}{% endif %}{% endfor %}">
<div class="block {% if line.fields|length_is:'1' and line.errors %} group errors{% endif %}{% if not line.has_visible_field %} hidden{% endif %}{% for field in line %}{% if field.field.name %} field-{{ field.field.name }}{% endif %}{% endfor %}">
{% for field in line %}
<div class="flex {% if not forloop.parentloop.last %} mb-6 {% else %} mb-3{% endif %} {% if row %}flex-row items-center{% else %}flex-col{% endif %}" {% if not line.fields|length_is:'1' %} class="fieldBox{% if field.field.name %} field-{{ field.field.name }}{% endif %}{% if not field.is_readonly and field.errors %} errors{% endif %}{% if field.field.is_hidden %} hidden{% endif %}"{% elif field.is_checkbox %} class="checkbox-row"{% endif %}>
{% if not line.fields|length_is:'1' and not field.is_readonly %}
Expand Down
1 change: 0 additions & 1 deletion src/unfold/templates/unfold/helpers/actions_row.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,3 @@
</ul>
</div>
{% endif %}

2 changes: 2 additions & 0 deletions src/unfold/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
"focus:ring-primary-300",
"focus:border-primary-600",
"focus:outline-none",
"group-[.errors]:border-red-600",
"group-[.errors]:focus:ring-red-200",
]

INPUT_CLASSES = [*BASE_INPUT_CLASSES, "max-w-2xl"]
Expand Down
26 changes: 13 additions & 13 deletions styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,6 @@ select:after {
display: none;
}

.block.errors input {
@apply border-red-600;
}

/*******************************************************
Table
*******************************************************/
Expand Down Expand Up @@ -474,17 +470,21 @@ fieldset.collapsed .collapse-toggle {
/*******************************************************
Errors
*******************************************************/
.errorlist li {
@apply bg-red-100 text-red-600 p-3 rounded-md text-sm;
}
/*.errorlist li {*/
/* @apply bg-red-100 text-red-600 p-3 rounded-md text-sm;*/
/*}*/

fieldset > .errorlist li {
@apply mb-3;
}
/*fieldset > .errorlist li {*/
/* @apply mb-3;*/
/*}*/

td > .errorlist li {
@apply mt-3 mx-3;
}
/*td > .errorlist li {*/
/* @apply mt-3 mx-3;*/
/*}*/

/*.block.errors input {*/
/* @apply border-red-600;*/
/*}*/

/*******************************************************
Misc
Expand Down

0 comments on commit b4e4a23

Please sign in to comment.