Comprehensive forms integration with djust, featuring real-time validation, error handling, and seamless LiveView integration.
User registration with password matching, username validation, and terms acceptance. Demonstrates field-level validation.
Contact form with dropdowns, radio buttons, and text areas. Shows various field types working together.
Profile editing with dates, URLs, and optional fields. Demonstrates complex field types and validation.
Automatic form rendering with framework-specific styling. Zero manual HTML - choose your CSS framework!
from djust import LiveView, FormMixin
from django import forms
class MyForm(forms.Form):
name = forms.CharField(max_length=100)
email = forms.EmailField()
class MyFormView(FormMixin, LiveView):
form_class = MyForm
def form_valid(self, form):
# Handle valid form submission
self.success_message = "Form submitted!"
def form_invalid(self, form):
# Handle errors
self.error_message = "Please fix errors"
<form @submit="submit_form">
<input name="name" @change="validate_field" data-field="name" />
{% if field_errors.name %}
<div class="error">{{ field_errors.name }}</div>
{% endif %}
<button type="submit">Submit</button>
</form>