2.9 KiB
2.9 KiB
Forms and Templates Fix Summary
Issue Identified
Multiple form templates across the project use hardcoded field IDs in JavaScript (e.g., $('#id_provider')), which may not match the actual Django-generated field IDs.
Templates That Need Fixing
The following templates have hardcoded IDs in their JavaScript:
- templates/aba/consult_form.html - Has
#id_provider, formset IDs - templates/medical/consultation_form.html - Needs checking
- templates/medical/followup_form.html - Needs checking
- templates/nursing/encounter_form.html - Needs checking
- templates/slp/assessment_form.html - Needs checking
- templates/slp/consultation_form.html - Needs checking
- templates/slp/intervention_form.html - Needs checking
- templates/slp/progress_form.html - Needs checking
- templates/referrals/referral_form.html - Needs checking
Solution
Replace hardcoded IDs with dynamic references using Django template variables:
Before (Wrong):
$('#id_provider').select2({...});
After (Correct):
var providerId = '#{{ form.provider.id_for_label }}';
$(providerId).select2({...});
Forms.py Status
All forms.py files have been updated with proper CSS classes:
- ✅ aba/forms.py - All fields have
form-controlclass - ✅ medical/forms.py - All fields have
form-controlclass - ✅ nursing/forms.py - All fields have
form-controlclass - ✅ ot/forms.py - All fields have
form-controlclass - ✅ slp/forms.py - All fields have
form-controlclass - ✅ appointments/forms.py - All fields have
form-controlclass - ✅ core/forms.py - Already had proper CSS classes
- ✅ finance/forms.py - Already had proper CSS classes
- ✅ referrals/forms.py - Already had proper CSS classes
Models.py Status
JSONFields converted to TextField for user-friendly input:
- ✅ aba/models.py - 2 fields converted
- ✅ ot/models.py - 8 fields converted
- ✅ slp/models.py - 13 fields converted
API Updates
- ✅ appointments/api_views.py - Added clinic filtering to ProviderViewSet
Templates Fixed
- ✅ templates/appointments/appointment_form.html - Dynamic IDs implemented
- ⚠️ templates/aba/consult_form.html - Needs dynamic IDs
- ⚠️ templates/medical/consultation_form.html - Needs checking
- ⚠️ templates/medical/followup_form.html - Needs checking
- ⚠️ templates/nursing/encounter_form.html - Needs checking
- ⚠️ templates/slp/*.html - Need checking
- ⚠️ templates/referrals/referral_form.html - Needs checking
Next Steps
- Fix all remaining templates to use dynamic field IDs
- Test each form to ensure JavaScript works correctly
- Run database migrations for model changes
- Verify all forms render with proper CSS styling
Database Migrations Required
python manage.py makemigrations
python manage.py migrate
This will apply the JSONField → TextField conversions.