Skip to content

Conversation

@hemant10yadav
Copy link
Contributor

@hemant10yadav hemant10yadav commented Dec 11, 2025

Technical Summary

https://dimagi.atlassian.net/browse/CCCT-1983

Fixes the Program Create/Update modal form to correctly display validation errors inside the modal when submitted via HTMX. Previously, validation errors rendered the full page, breaking the modal UI. Uses a dedicated HTMX partial for the form and preserves styling, while successful submissions close the modal and redirect cleanly using HX-Redirect.

This issue was noticed following a recent P1 issue. Although the P1 issue was slightly different, this bug is primarily a UI-related.

Safety Assurance

Safety story

Tested locally

Automated test coverage

NA

QA Plan

NA

Labels & Review

  • The set of people pinged as reviewers is appropriate for the level of risk of the change

@hemant10yadav hemant10yadav self-assigned this Dec 11, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 11, 2025

Walkthrough

The pull request integrates HTMX functionality into the ProgramCreateOrUpdate view to handle form submissions asynchronously. Changes include adding an HttpResponse import, overriding form_invalid() and get_context_data() methods to provide HTMX-specific context, modifying form_valid() to return HTMX redirect headers, and updating the program form template to use HTMX attributes (hx-post, hx-target, hx-swap) instead of traditional Django form action resolution.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • commcare_connect/program/views.py: Multiple method overrides with conditional logic based on request.htmx state; requires verification of form handling flow and HTMX integration patterns
  • commcare_connect/templates/program/program_form.html: Template logic conversion from server-side URL resolution to client-side HTMX attributes; ensure proper integration with context variables and form submission behavior

Suggested reviewers

  • Charl1996
  • pxwxnvermx
  • zandre-eng
  • ajeety4

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Fix HTMX Modal Behaviour for Program Create/Update Form Submissions' directly and clearly describes the main change: fixing HTMX modal form behavior for program create/update operations.
Description check ✅ Passed The pull request description clearly explains the purpose of the changes: fixing modal form validation error handling in HTMX submissions and improving the form submission flow.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch hy/progform

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants