Skip to content

Commit 67b0f66

Browse files
committed
fix: include forms.css directly in templates + phone real-time validation
The package base.html (which includes forms.css) is overridden by host apps that provide their own base.html, silently dropping all alignment CSS. Include the stylesheet directly in form_submit, approve, and form_embed templates via the extra_css block. Also add a 'phone' validation rule type to get_enhancements_config() and form-enhancements.js so phone fields get immediate input-time red/green feedback like email fields do. Bump version to 0.63.4.
1 parent 71bb628 commit 67b0f66

7 files changed

Lines changed: 36 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [0.63.4] - 2026-04-02
11+
12+
### Fixed
13+
- **forms.css now loaded in form_submit, approve, and form_embed templates**
14+
the package's `base.html` (which includes `forms.css`) was being overridden
15+
by host apps that provide their own `base.html` template, causing all
16+
alignment CSS to be silently dropped. The stylesheet is now included directly
17+
in each template's `extra_css` block so it loads regardless of base template
18+
overrides.
19+
- **Phone field real-time validation** — added a `phone` validation rule type
20+
to `get_enhancements_config()` and `form-enhancements.js` so phone fields
21+
get immediate red/green feedback on input (like email fields), rejecting
22+
non-phone text such as "test" before form submission.
23+
1024
## [0.63.3] - 2026-04-02
1125

1226
### Fixed

django_forms_workflows/forms.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1254,6 +1254,17 @@ def get_enhancements_config(self):
12541254
{"type": "email", "message": "Please enter a valid email address"}
12551255
)
12561256

1257+
if field.field_type == "phone":
1258+
validation_rules.append(
1259+
{
1260+
"type": "phone",
1261+
"message": (
1262+
"Enter a valid phone number, e.g. 2065551234, "
1263+
"(206) 555-1234, or +1 (206) 555-1234"
1264+
),
1265+
}
1266+
)
1267+
12571268
if field.field_type == "url":
12581269
validation_rules.append(
12591270
{"type": "url", "message": "Please enter a valid URL"}

django_forms_workflows/static/django_forms_workflows/js/form-enhancements.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,10 @@ class FormEnhancements {
453453
(!Array.isArray(value) || value.length > 0);
454454
case 'email':
455455
return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value);
456+
case 'phone':
457+
// Must contain at least 7 digits; only digits, spaces, dashes,
458+
// dots, parens, and an optional leading + are allowed.
459+
return /^\+?[\d()\- .]{7,25}$/.test(value) && (value.match(/\d/g) || []).length >= 7;
456460
case 'url':
457461
try {
458462
new URL(value);

django_forms_workflows/templates/django_forms_workflows/approve.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55

66
{% block title %}Approve Submission #{{ submission.id }} - {{ site_name }}{% endblock %}
77

8+
{% block extra_css %}
9+
<link rel="stylesheet" href="{% static 'django_forms_workflows/css/forms.css' %}">
10+
{% endblock %}
11+
812
{% block content %}
913
<div class="row">
1014
<div class="col-lg-10 mx-auto">

django_forms_workflows/templates/django_forms_workflows/form_embed.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
{% block title %}{{ form_def.name }}{% endblock %}
66

77
{% block extra_css %}
8+
<link rel="stylesheet" href="{% static 'django_forms_workflows/css/forms.css' %}">
89
<style>
910
.rating-stars-container { display: inline-flex; gap: 0.15rem; direction: rtl; }
1011
.rating-stars-container input { display: none; }

django_forms_workflows/templates/django_forms_workflows/form_submit.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
{% block title %}{{ form_def.name }} - {{ site_name }}{% endblock %}
66

77
{% block extra_css %}
8+
<link rel="stylesheet" href="{% static 'django_forms_workflows/css/forms.css' %}">
89
<style>
910
/* Rating stars widget */
1011
.rating-stars-container { display: inline-flex; gap: 0.15rem; direction: rtl; }

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "django-forms-workflows"
3-
version = "0.63.3"
3+
version = "0.63.4"
44
description = "Enterprise-grade, database-driven form builder with approval workflows and external data integration"
55
license = "LGPL-3.0-only"
66
readme = "README.md"

0 commit comments

Comments
 (0)