Demonstrates ALL library features: model lists, sections, all input types Async
<form id=""
class="pydantic-form needs-validation"
style=""
method="POST"
action="/showcase"
novalidate>
<div class="mb-3"><label for="first_name"><i class="bi bi-person"></i> First Name *</label>
<input name="first_name" id="first_name" class="form-control" value="Alex" required="required" minlength="2" maxlength="11" placeholder="Enter your first name" pattern="\d{3}-\d{2}-\d{4}" inputmode="numeric" autocomplete="off" type="text" />
<div class="form-text">Your given name as it appears on official documents</div></div>
<div class="mb-3"><label for="last_name"><i class="bi bi-person"></i> Last Name *</label>
<input name="last_name" id="last_name" class="form-control" value="Johnson" required="required" minlength="2" maxlength="11" placeholder="Enter your last name" pattern="\d{3}-\d{2}-\d{4}" inputmode="numeric" autocomplete="off" type="text" />
<div class="form-text">Your family name or surname</div></div>
<div class="mb-3"><label for="email"><i class="bi bi-envelope"></i> Email Address *</label>
<input name="email" id="email" class="form-control" value="alex.johnson@example.com" required="required" placeholder="your.email@example.com" inputmode="email" type="email" />
<div class="form-text">We'll use this to contact you about your registration</div></div>
<div class="mb-3"><label for="phone"><i class="bi bi-telephone"></i> Phone Number</label>
<input name="phone" id="phone" class="form-control" value="+1 (555) 234-5678" placeholder="+1 (555) 123-4567" inputmode="tel" autocomplete="tel" type="tel" />
<div class="form-text">Include country code for international numbers</div></div>
<div class="mb-3"><label for="birth_date"><i class="bi bi-calendar-date"></i> Date of Birth</label>
<div class="birthdate-input-group"><input name="birth_date" id="birth_date" class="form-control" value="1995-06-15" max="2026-01-07" min="1876-01-01" type="date" />
<div class="age-display" id="birth_date_age" style="margin-top: 5px; font-size: 0.9em; color: #666;"></div>
<script>
document.addEventListener('DOMContentLoaded', function() {
const birthdateField = document.getElementById('birth_date');
const ageDisplay = document.getElementById('birth_date_age');
function calculateAge() {
if (birthdateField.value && ageDisplay) {
const birthDate = new Date(birthdateField.value);
const today = new Date();
let age = today.getFullYear() - birthDate.getFullYear();
const monthDiff = today.getMonth() - birthDate.getMonth();
if (monthDiff < 0 || (monthDiff === 0 && today.getDate() < birthDate.getDate())) {
age--;
}
ageDisplay.textContent = age >= 0 ? `Age: ${age} years` : '';
}
}
if (birthdateField) {
birthdateField.addEventListener('change', calculateAge);
calculateAge(); // Calculate on load if value is set
}
});
</script>
</div>
<div class="form-text">Used to verify age requirements (optional)</div></div>
<div class="mb-3"><label for="age"><i class="bi bi-hash"></i> Age</label>
<input name="age" id="age" class="form-control" value="28" placeholder="25%" min="0" max="100" step="0.1" inputmode="numeric" type="number" />
<div class="form-text">Your current age in years</div></div>
<div class="mb-3"><label for="favorite_color"><i class="bi bi-palette"></i> Favorite Color</label>
<div class="color-input-group"><input name="favorite_color" id="favorite_color" class="form-control" value="#3498db" type="color" />
<div class="color-value-display" style="display: inline-flex; align-items: center; margin-left: 10px;">
<span id="favorite_color_value" style="font-family: monospace;">#3498db</span>
<div id="favorite_color_swatch" style="width: 20px; height: 20px; background-color: #3498db; border: 1px solid #ccc; margin-left: 5px;"></div>
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
const colorInput = document.getElementById('favorite_color');
const valueSpan = document.getElementById('favorite_color_value');
const swatch = document.getElementById('favorite_color_swatch');
if (colorInput && valueSpan && swatch) {
colorInput.addEventListener('input', function() {
valueSpan.textContent = this.value;
swatch.style.backgroundColor = this.value;
});
}
});
</script>
</div>
<div class="form-text">Pick your favorite color</div></div>
<div class="mb-3"><div class="mb-3">
<label for="experience_level" class="form-label">Experience Level</label>
<div class="input-group">
<span class="input-group-text"><i class="bi bi-bi bi-trophy"></i></span>
<select name="experience_level" id="experience_level" class="form-select" required="required"><option value="beginner">π± Beginner (0-1 years)</option>
<option value="intermediate" selected>π Intermediate (2-5 years)</option>
<option value="advanced">π― Advanced (5-10 years)</option>
<option value="expert">π Expert (10+ years)</option></select>
</div>
<div class="form-text">Select your experience level</div>
</div></div>
<div class="mb-3"><label for="newsletter_subscription"><i class="bi bi-mailbox"></i> Subscribe to Newsletter</label>
<input name="newsletter_subscription" id="newsletter_subscription" class="form-check-input" checked="checked" value="1" type="checkbox" />
<div class="form-text">Receive updates and news about our services</div></div>
<div class="mb-3"><label for="rating"><i class="bi bi-star"></i> Rate Your Interest (1-10)</label>
<input name="rating" id="rating" class="form-control" value="8" min="1" max="5" step="1" type="range" />
<div class="star-rating" id="rating-stars">
β
β
β
β
β
β
β
β
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
const range = document.getElementById('rating');
const stars = document.getElementById('rating-stars');
if (range && stars) {
range.addEventListener('input', function() {
const value = parseInt(this.value);
const maxRating = 5;
stars.textContent = 'β
'.repeat(value) + 'β'.repeat(maxRating - value);
});
}
});
</script>
<div class="form-text">How interested are you in our services?</div></div>
<div class="mb-3"><label for="address"><i class="bi bi-house"></i> Street Address</label>
<textarea name="address" id="address" class="form-control" placeholder="123 Main Street
Apt 4B">456 Oak Avenue
Unit 12
Downtown District</textarea>
<div class="form-text">Your full mailing address (optional)</div></div>
<div class="mb-3"><div class="mb-3">
<label for="country" class="form-label">Country</label>
<div class="input-group">
<span class="input-group-text"><i class="bi bi-bi bi-globe"></i></span>
<select name="country" id="country" class="form-select"><option value="US" selected>πΊπΈ United States</option>
<option value="CA">π¨π¦ Canada</option>
<option value="UK">π¬π§ United Kingdom</option>
<option value="DE">π©πͺ Germany</option>
<option value="FR">π«π· France</option>
<option value="AU">π¦πΊ Australia</option>
<option value="OTHER">π Other</option></select>
</div>
<div class="form-text">Select your country of residence</div>
</div></div>
<div class="mb-3 model-list-block" data-field-name="pets" data-min-items="0" data-max-items="5">
<label class="form-label fw-bold">Your Pets <span class="text-danger">*</span></label>
<div class="model-list-container" data-field-name="pets" data-min-items="0" data-max-items="5">
<div class="model-list-items" id="pets-items">
<div class="model-list-item card border mb-3"
data-index="0"
data-title-template="πΎ {name} the {species}"
data-field-name="pets">
<div class="card-header d-flex justify-content-between align-items-center">
<h6 class="mb-0">
<button class="btn btn-link text-decoration-none p-0 text-start"
type="button"
data-bs-toggle="collapse"
data-bs-target="#pets_item_0_content"
aria-expanded="false"
aria-controls="pets_item_0_content">
<i class="bi bi-chevron-right me-2"></i>
<i class="bi bi-card-list me-2"></i>
πΎ Buddy the dog
</button>
</h6>
<button type="button"
class="btn btn-outline-danger btn-sm remove-item-btn"
data-index="0"
data-field-name="pets"
title="Remove this item">
<i class="bi bi-trash"></i>
</button>
</div>
<div class="collapse collapse show" id="pets_item_0_content">
<div class="card-body"><div class="row">
<div class="col-lg-4 col-md-6">
<div class="mb-3"><label for="pets[0].name"><i class="bi bi-heart"></i> Pet's Name</label>
<input name="pets[0].name" id="pets[0].name" class="form-control" value="Buddy" minlength="1" maxlength="11" placeholder="Enter your pet's name" pattern="\d{3}-\d{2}-\d{4}" inputmode="numeric" autocomplete="off" type="text" />
<div class="form-text">The name of your pet</div></div>
</div>
<div class="col-lg-4 col-md-6">
<div class="mb-3"><div class="mb-3">
<label for="pets[0].species" class="form-label">Species</label>
<div class="input-group">
<span class="input-group-text"><i class="bi bi-bi bi-collection"></i></span>
<select name="pets[0].species" id="pets[0].species" class="form-select"><option value="Dog">Dog π</option>
<option value="Cat">Cat π±</option>
<option value="Bird">Bird π¦</option>
<option value="Fish">Fish π </option>
<option value="Rabbit">Rabbit π°</option>
<option value="Hamster">Hamster πΉ</option>
<option value="Reptile">Reptile π¦</option>
<option value="Other">Other πΎ</option></select>
</div>
<div class="form-text">What type of animal is your pet?</div>
</div></div>
</div>
<div class="col-lg-4 col-md-6">
<div class="mb-3"><label for="pets[0].age"><i class="bi bi-calendar"></i> Age</label>
<input name="pets[0].age" id="pets[0].age" class="form-control" value="4" placeholder="Pet's age in years%" min="0" max="100" step="0.1" inputmode="numeric" type="number" />
<div class="form-text">How old is your pet? (optional)</div></div>
</div>
<div class="col-lg-4 col-md-6">
<div class="mb-3"><label for="pets[0].weight"><i class="bi bi-speedometer2"></i> Weight (lbs)</label>
<input name="pets[0].weight" id="pets[0].weight" class="form-control" value="70.0" placeholder="Pet's weight%" min="0" max="100" step="0.1" inputmode="numeric" type="number" />
<div class="form-text">Weight in pounds (optional - enter 0.01 for tiny pets like birds)</div></div>
</div>
<div class="col-lg-4 col-md-6">
<div class="mb-3"><label for="pets[0].is_vaccinated"><i class="bi bi-shield-check"></i> Vaccinated</label>
<input name="pets[0].is_vaccinated" id="pets[0].is_vaccinated" class="form-check-input" value="1" type="checkbox" />
<div class="form-text">Is your pet up to date with vaccinations?</div></div>
</div>
<div class="col-lg-4 col-md-6">
<div class="mb-3"><label for="pets[0].microchipped"><i class="bi bi-cpu"></i> Microchipped</label>
<input name="pets[0].microchipped" id="pets[0].microchipped" class="form-check-input" checked="checked" value="1" type="checkbox" />
<div class="form-text">Does your pet have a microchip?</div></div>
</div>
<div class="col-lg-4 col-md-6">
<div class="mb-3"><label for="pets[0].breed"><i class="bi bi-award"></i> Breed</label>
<input name="pets[0].breed" id="pets[0].breed" class="form-control" value="Labrador" placeholder="e.g., Golden Retriever, Persian Cat" pattern="\d{3}-\d{2}-\d{4}" maxlength="11" inputmode="numeric" autocomplete="off" type="text" />
<div class="form-text">Specific breed of your pet (optional)</div></div>
</div>
<div class="col-lg-4 col-md-6">
<div class="mb-3"><label for="pets[0].color"><i class="bi bi-palette"></i> Primary Color</label>
<div class="color-input-group"><input name="pets[0].color" id="pets[0].color" class="form-control" type="color" />
<div class="color-value-display" style="display: inline-flex; align-items: center; margin-left: 10px;">
<span id="pets[0].color_value" style="font-family: monospace;"></span>
<div id="pets[0].color_swatch" style="width: 20px; height: 20px; background-color: ; border: 1px solid #ccc; margin-left: 5px;"></div>
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
const colorInput = document.getElementById('pets[0].color');
const valueSpan = document.getElementById('pets[0].color_value');
const swatch = document.getElementById('pets[0].color_swatch');
if (colorInput && valueSpan && swatch) {
colorInput.addEventListener('input', function() {
valueSpan.textContent = this.value;
swatch.style.backgroundColor = this.value;
});
}
});
</script>
</div>
<div class="form-text">Primary color of your pet (optional)</div></div>
</div>
<div class="col-lg-4 col-md-6">
<div class="mb-3"><label for="pets[0].last_vet_visit"><i class="bi bi-calendar-date"></i> Last Vet Visit</label>
<div class="birthdate-input-group"><input name="pets[0].last_vet_visit" id="pets[0].last_vet_visit" class="form-control" max="2026-01-07" min="1876-01-01" type="date" />
<div class="age-display" id="pets[0].last_vet_visit_age" style="margin-top: 5px; font-size: 0.9em; color: #666;"></div>
<script>
document.addEventListener('DOMContentLoaded', function() {
const birthdateField = document.getElementById('pets[0].last_vet_visit');
const ageDisplay = document.getElementById('pets[0].last_vet_visit_age');
function calculateAge() {
if (birthdateField.value && ageDisplay) {
const birthDate = new Date(birthdateField.value);
const today = new Date();
let age = today.getFullYear() - birthDate.getFullYear();
const monthDiff = today.getMonth() - birthDate.getMonth();
if (monthDiff < 0 || (monthDiff === 0 && today.getDate() < birthDate.getDate())) {
age--;
}
ageDisplay.textContent = age >= 0 ? `Age: ${age} years` : '';
}
}
if (birthdateField) {
birthdateField.addEventListener('change', calculateAge);
calculateAge(); // Calculate on load if value is set
}
});
</script>
</div>
<div class="form-text">When was the last veterinary checkup? (optional)</div></div>
</div>
<div class="col-lg-4 col-md-6">
<div class="mb-3"><label for="pets[0].special_needs"><i class="bi bi-heart-pulse"></i> Special Needs</label>
<textarea name="pets[0].special_needs" id="pets[0].special_needs" class="form-control" placeholder="Any special care requirements, medications, allergies, etc.">Needs hip medication twice daily</textarea>
<div class="form-text">Describe any special care requirements (optional)</div></div>
</div></div>
</div>
</div>
</div>
<div class="model-list-item card border mb-3"
data-index="1"
data-title-template="πΎ {name} the {species}"
data-field-name="pets">
<div class="card-header d-flex justify-content-between align-items-center">
<h6 class="mb-0">
<button class="btn btn-link text-decoration-none p-0 text-start"
type="button"
data-bs-toggle="collapse"
data-bs-target="#pets_item_1_content"
aria-expanded="false"
aria-controls="pets_item_1_content">
<i class="bi bi-chevron-right me-2"></i>
<i class="bi bi-card-list me-2"></i>
πΎ Whiskers the cat
</button>
</h6>
<button type="button"
class="btn btn-outline-danger btn-sm remove-item-btn"
data-index="1"
data-field-name="pets"
title="Remove this item">
<i class="bi bi-trash"></i>
</button>
</div>
<div class="collapse collapse show" id="pets_item_1_content">
<div class="card-body"><div class="row">
<div class="col-lg-4 col-md-6">
<div class="mb-3"><label for="pets[1].name"><i class="bi bi-heart"></i> Pet's Name</label>
<input name="pets[1].name" id="pets[1].name" class="form-control" value="Whiskers" minlength="1" maxlength="11" placeholder="Enter your pet's name" pattern="\d{3}-\d{2}-\d{4}" inputmode="numeric" autocomplete="off" type="text" />
<div class="form-text">The name of your pet</div></div>
</div>
<div class="col-lg-4 col-md-6">
<div class="mb-3"><div class="mb-3">
<label for="pets[1].species" class="form-label">Species</label>
<div class="input-group">
<span class="input-group-text"><i class="bi bi-bi bi-collection"></i></span>
<select name="pets[1].species" id="pets[1].species" class="form-select"><option value="Dog">Dog π</option>
<option value="Cat">Cat π±</option>
<option value="Bird">Bird π¦</option>
<option value="Fish">Fish π </option>
<option value="Rabbit">Rabbit π°</option>
<option value="Hamster">Hamster πΉ</option>
<option value="Reptile">Reptile π¦</option>
<option value="Other">Other πΎ</option></select>
</div>
<div class="form-text">What type of animal is your pet?</div>
</div></div>
</div>
<div class="col-lg-4 col-md-6">
<div class="mb-3"><label for="pets[1].age"><i class="bi bi-calendar"></i> Age</label>
<input name="pets[1].age" id="pets[1].age" class="form-control" value="5" placeholder="Pet's age in years%" min="0" max="100" step="0.1" inputmode="numeric" type="number" />
<div class="form-text">How old is your pet? (optional)</div></div>
</div>
<div class="col-lg-4 col-md-6">
<div class="mb-3"><label for="pets[1].weight"><i class="bi bi-speedometer2"></i> Weight (lbs)</label>
<input name="pets[1].weight" id="pets[1].weight" class="form-control" value="12.5" placeholder="Pet's weight%" min="0" max="100" step="0.1" inputmode="numeric" type="number" />
<div class="form-text">Weight in pounds (optional - enter 0.01 for tiny pets like birds)</div></div>
</div>
<div class="col-lg-4 col-md-6">
<div class="mb-3"><label for="pets[1].is_vaccinated"><i class="bi bi-shield-check"></i> Vaccinated</label>
<input name="pets[1].is_vaccinated" id="pets[1].is_vaccinated" class="form-check-input" value="1" type="checkbox" />
<div class="form-text">Is your pet up to date with vaccinations?</div></div>
</div>
<div class="col-lg-4 col-md-6">
<div class="mb-3"><label for="pets[1].microchipped"><i class="bi bi-cpu"></i> Microchipped</label>
<input name="pets[1].microchipped" id="pets[1].microchipped" class="form-check-input" checked="checked" value="1" type="checkbox" />
<div class="form-text">Does your pet have a microchip?</div></div>
</div>
<div class="col-lg-4 col-md-6">
<div class="mb-3"><label for="pets[1].breed"><i class="bi bi-award"></i> Breed</label>
<input name="pets[1].breed" id="pets[1].breed" class="form-control" value="Maine Coon" placeholder="e.g., Golden Retriever, Persian Cat" pattern="\d{3}-\d{2}-\d{4}" maxlength="11" inputmode="numeric" autocomplete="off" type="text" />
<div class="form-text">Specific breed of your pet (optional)</div></div>
</div>
<div class="col-lg-4 col-md-6">
<div class="mb-3"><label for="pets[1].color"><i class="bi bi-palette"></i> Primary Color</label>
<div class="color-input-group"><input name="pets[1].color" id="pets[1].color" class="form-control" type="color" />
<div class="color-value-display" style="display: inline-flex; align-items: center; margin-left: 10px;">
<span id="pets[1].color_value" style="font-family: monospace;"></span>
<div id="pets[1].color_swatch" style="width: 20px; height: 20px; background-color: ; border: 1px solid #ccc; margin-left: 5px;"></div>
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
const colorInput = document.getElementById('pets[1].color');
const valueSpan = document.getElementById('pets[1].color_value');
const swatch = document.getElementById('pets[1].color_swatch');
if (colorInput && valueSpan && swatch) {
colorInput.addEventListener('input', function() {
valueSpan.textContent = this.value;
swatch.style.backgroundColor = this.value;
});
}
});
</script>
</div>
<div class="form-text">Primary color of your pet (optional)</div></div>
</div>
<div class="col-lg-4 col-md-6">
<div class="mb-3"><label for="pets[1].last_vet_visit"><i class="bi bi-calendar-date"></i> Last Vet Visit</label>
<div class="birthdate-input-group"><input name="pets[1].last_vet_visit" id="pets[1].last_vet_visit" class="form-control" max="2026-01-07" min="1876-01-01" type="date" />
<div class="age-display" id="pets[1].last_vet_visit_age" style="margin-top: 5px; font-size: 0.9em; color: #666;"></div>
<script>
document.addEventListener('DOMContentLoaded', function() {
const birthdateField = document.getElementById('pets[1].last_vet_visit');
const ageDisplay = document.getElementById('pets[1].last_vet_visit_age');
function calculateAge() {
if (birthdateField.value && ageDisplay) {
const birthDate = new Date(birthdateField.value);
const today = new Date();
let age = today.getFullYear() - birthDate.getFullYear();
const monthDiff = today.getMonth() - birthDate.getMonth();
if (monthDiff < 0 || (monthDiff === 0 && today.getDate() < birthDate.getDate())) {
age--;
}
ageDisplay.textContent = age >= 0 ? `Age: ${age} years` : '';
}
}
if (birthdateField) {
birthdateField.addEventListener('change', calculateAge);
calculateAge(); // Calculate on load if value is set
}
});
</script>
</div>
<div class="form-text">When was the last veterinary checkup? (optional)</div></div>
</div>
<div class="col-lg-4 col-md-6">
<div class="mb-3"><label for="pets[1].special_needs"><i class="bi bi-heart-pulse"></i> Special Needs</label>
<textarea name="pets[1].special_needs" id="pets[1].special_needs" class="form-control" placeholder="Any special care requirements, medications, allergies, etc.">Requires grain-free diet</textarea>
<div class="form-text">Describe any special care requirements (optional)</div></div>
</div></div>
</div>
</div>
</div></div>
<div class="model-list-controls mt-2">
<button type="button" class="btn btn-outline-primary btn-sm add-item-btn" data-target="pets">
<i class="bi bi-plus-circle"></i> Add Item
</button>
</div>
</div>
<div class="form-text text-muted model-list-help">Tell us about each of your beloved pets</div>
</div>
<div class="mb-3 model-list-block" data-field-name="emergency_contacts" data-min-items="1" data-max-items="3">
<label class="form-label fw-bold">Emergency Contacts <span class="text-danger">*</span></label>
<div class="model-list-container" data-field-name="emergency_contacts" data-min-items="1" data-max-items="3">
<div class="model-list-items" id="emergency_contacts-items">
<div class="model-list-item card border mb-3"
data-index="0"
data-title-template="π {name} ({relationship})"
data-field-name="emergency_contacts">
<div class="card-header d-flex justify-content-between align-items-center">
<h6 class="mb-0">
<button class="btn btn-link text-decoration-none p-0 text-start"
type="button"
data-bs-toggle="collapse"
data-bs-target="#emergency_contacts_item_0_content"
aria-expanded="true"
aria-controls="emergency_contacts_item_0_content">
<i class="bi bi-chevron-down me-2"></i>
<i class="bi bi-card-list me-2"></i>
π Emma Johnson (spouse)
</button>
</h6>
<button type="button"
class="btn btn-outline-danger btn-sm remove-item-btn"
data-index="0"
data-field-name="emergency_contacts"
title="Remove this item">
<i class="bi bi-trash"></i>
</button>
</div>
<div class="collapse show" id="emergency_contacts_item_0_content">
<div class="card-body"><div class="row">
<div class="col-lg-4 col-md-6">
<div class="mb-3"><label for="emergency_contacts[0].name"><i class="bi bi-person-badge"></i> Contact Name</label>
<input name="emergency_contacts[0].name" id="emergency_contacts[0].name" class="form-control" value="Emma Johnson" minlength="2" maxlength="11" placeholder="John Doe" pattern="\d{3}-\d{2}-\d{4}" inputmode="numeric" autocomplete="off" type="text" />
<div class="form-text">Full name of emergency contact</div></div>
</div>
<div class="col-lg-4 col-md-6">
<div class="mb-3"><div class="mb-3">
<label for="emergency_contacts[0].relationship" class="form-label">Relationship</label>
<div class="input-group">
<span class="input-group-text"><i class="bi bi-bi bi-people"></i></span>
<select name="emergency_contacts[0].relationship" id="emergency_contacts[0].relationship" class="form-select"><option value="spouse" selected>π Spouse/Partner</option>
<option value="parent">π¨βπ©βπ§βπ¦ Parent</option>
<option value="child">πΆ Child</option>
<option value="sibling">π« Sibling</option>
<option value="friend">π₯ Friend</option>
<option value="colleague">πΌ Colleague</option>
<option value="other">π€ Other</option></select>
</div>
<div class="form-text">Your relationship to this person</div>
</div></div>
</div>
<div class="col-lg-4 col-md-6">
<div class="mb-3"><label for="emergency_contacts[0].phone"><i class="bi bi-telephone"></i> Phone Number</label>
<input name="emergency_contacts[0].phone" id="emergency_contacts[0].phone" class="form-control" value="+1 (555) 345-6789" minlength="10" maxlength="20" placeholder="+1 (555) 123-4567" inputmode="tel" autocomplete="tel" type="tel" />
<div class="form-text">Primary phone number for this contact</div></div>
</div>
<div class="col-lg-4 col-md-6">
<div class="mb-3"><label for="emergency_contacts[0].email"><i class="bi bi-envelope"></i> Email Address</label>
<input name="emergency_contacts[0].email" id="emergency_contacts[0].email" class="form-control" value="emma.johnson@example.com" placeholder="contact@example.com" inputmode="email" type="email" />
<div class="form-text">Email address (optional)</div></div>
</div>
<div class="col-lg-4 col-md-6">
<div class="mb-3"><label for="emergency_contacts[0].available_24_7"><i class="bi bi-clock"></i> Available 24/7</label>
<input name="emergency_contacts[0].available_24_7" id="emergency_contacts[0].available_24_7" class="form-check-input" checked="checked" value="1" type="checkbox" />
<div class="form-text">Can this person be contacted at any time?</div></div>
</div></div>
</div>
</div>
</div>
<div class="model-list-item card border mb-3"
data-index="1"
data-title-template="π {name} ({relationship})"
data-field-name="emergency_contacts">
<div class="card-header d-flex justify-content-between align-items-center">
<h6 class="mb-0">
<button class="btn btn-link text-decoration-none p-0 text-start"
type="button"
data-bs-toggle="collapse"
data-bs-target="#emergency_contacts_item_1_content"
aria-expanded="true"
aria-controls="emergency_contacts_item_1_content">
<i class="bi bi-chevron-down me-2"></i>
<i class="bi bi-card-list me-2"></i>
π Robert Johnson (parent)
</button>
</h6>
<button type="button"
class="btn btn-outline-danger btn-sm remove-item-btn"
data-index="1"
data-field-name="emergency_contacts"
title="Remove this item">
<i class="bi bi-trash"></i>
</button>
</div>
<div class="collapse show" id="emergency_contacts_item_1_content">
<div class="card-body"><div class="row">
<div class="col-lg-4 col-md-6">
<div class="mb-3"><label for="emergency_contacts[1].name"><i class="bi bi-person-badge"></i> Contact Name</label>
<input name="emergency_contacts[1].name" id="emergency_contacts[1].name" class="form-control" value="Robert Johnson" minlength="2" maxlength="11" placeholder="John Doe" pattern="\d{3}-\d{2}-\d{4}" inputmode="numeric" autocomplete="off" type="text" />
<div class="form-text">Full name of emergency contact</div></div>
</div>
<div class="col-lg-4 col-md-6">
<div class="mb-3"><div class="mb-3">
<label for="emergency_contacts[1].relationship" class="form-label">Relationship</label>
<div class="input-group">
<span class="input-group-text"><i class="bi bi-bi bi-people"></i></span>
<select name="emergency_contacts[1].relationship" id="emergency_contacts[1].relationship" class="form-select"><option value="spouse">π Spouse/Partner</option>
<option value="parent" selected>π¨βπ©βπ§βπ¦ Parent</option>
<option value="child">πΆ Child</option>
<option value="sibling">π« Sibling</option>
<option value="friend">π₯ Friend</option>
<option value="colleague">πΌ Colleague</option>
<option value="other">π€ Other</option></select>
</div>
<div class="form-text">Your relationship to this person</div>
</div></div>
</div>
<div class="col-lg-4 col-md-6">
<div class="mb-3"><label for="emergency_contacts[1].phone"><i class="bi bi-telephone"></i> Phone Number</label>
<input name="emergency_contacts[1].phone" id="emergency_contacts[1].phone" class="form-control" value="+1 (555) 456-7890" minlength="10" maxlength="20" placeholder="+1 (555) 123-4567" inputmode="tel" autocomplete="tel" type="tel" />
<div class="form-text">Primary phone number for this contact</div></div>
</div>
<div class="col-lg-4 col-md-6">
<div class="mb-3"><label for="emergency_contacts[1].email"><i class="bi bi-envelope"></i> Email Address</label>
<input name="emergency_contacts[1].email" id="emergency_contacts[1].email" class="form-control" value="robert.johnson@example.com" placeholder="contact@example.com" inputmode="email" type="email" />
<div class="form-text">Email address (optional)</div></div>
</div>
<div class="col-lg-4 col-md-6">
<div class="mb-3"><label for="emergency_contacts[1].available_24_7"><i class="bi bi-clock"></i> Available 24/7</label>
<input name="emergency_contacts[1].available_24_7" id="emergency_contacts[1].available_24_7" class="form-check-input" value="1" type="checkbox" />
<div class="form-text">Can this person be contacted at any time?</div></div>
</div></div>
</div>
</div>
</div></div>
<div class="model-list-controls mt-2">
<button type="button" class="btn btn-outline-primary btn-sm add-item-btn" data-target="emergency_contacts">
<i class="bi bi-plus-circle"></i> Add Item
</button>
</div>
</div>
<div class="form-text text-muted model-list-help">Add people we can contact in case of emergency</div>
</div>
<div class="mb-3"><label for="special_requests"><i class="bi bi-chat-dots"></i> Special Requests or Comments</label>
<textarea name="special_requests" id="special_requests" class="form-control" placeholder="Any special requests, dietary restrictions, accessibility needs, or additional comments...">Please contact me via email for all communications. I work night shifts and may not be available by phone during the day.</textarea>
<div class="form-text">Let us know about any special accommodations you need</div></div>
<div class="mb-3"><label for="terms_accepted"><i class="bi bi-check-square"></i> I accept the Terms and Conditions</label>
<input name="terms_accepted" id="terms_accepted" class="form-check-input" checked="checked" value="1" type="checkbox" />
<div class="form-text">You must accept the terms to proceed</div></div>
<button type="submit" class="btn btn-primary">Submit</button>
</form>
<script>
(function() {
document.addEventListener('DOMContentLoaded', function() {
// Prevent Enter key from submitting forms unless on submit button
const forms = document.querySelectorAll('form.pydantic-form');
forms.forEach(function(form) {
form.addEventListener('keydown', function(e) {
// Check if Enter key is pressed
if (e.key === 'Enter' || e.keyCode === 13) {
const target = e.target;
// Allow Enter in textareas (for multi-line input)
if (target.tagName === 'TEXTAREA') {
return;
}
// Allow Enter on submit buttons
if (target.tagName === 'BUTTON' && target.type === 'submit') {
return;
}
// Allow Enter on input type="submit"
if (target.tagName === 'INPUT' && target.type === 'submit') {
return;
}
// Prevent form submission for all other cases
e.preventDefault();
return false;
}
});
});
});
})();
</script>
<script>
(function() {
'use strict';
// Ensure this runs after DOM is loaded
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', initializeModelLists);
} else {
initializeModelLists();
}
function initializeModelLists() {
// Add item functionality
const addButtons = document.querySelectorAll('.add-item-btn');
addButtons.forEach(button => {
if (!button.hasAttribute('data-initialized')) {
button.setAttribute('data-initialized', 'true');
button.addEventListener('click', handleAddItem);
}
});
// Remove item functionality - use direct event listeners
const removeButtons = document.querySelectorAll('.remove-item-btn');
removeButtons.forEach(button => {
if (!button.hasAttribute('data-initialized')) {
button.setAttribute('data-initialized', 'true');
button.addEventListener('click', handleRemoveItem);
}
});
// Also set up delegation for dynamically added buttons
document.addEventListener('click', function(e) {
if (e.target.closest('.remove-item-btn') && !e.target.closest('.remove-item-btn').hasAttribute('data-initialized')) {
const button = e.target.closest('.remove-item-btn');
button.setAttribute('data-initialized', 'true');
handleRemoveItem.call(button, e);
}
});
}
function handleAddItem(e) {
e.preventDefault();
e.stopPropagation();
const fieldName = this.dataset.target;
const container = document.querySelector(`[data-field-name="${fieldName}"]`);
if (!container) return;
const itemsContainer = container.querySelector('.model-list-items');
const maxItems = parseInt(container.dataset.maxItems || '10');
const currentItems = itemsContainer.querySelectorAll('.model-list-item').length;
if (currentItems >= maxItems) {
alert(`Maximum ${maxItems} items allowed.`);
return;
}
addNewListItem(fieldName, currentItems);
updateItemIndices(itemsContainer);
}
function handleRemoveItem(e) {
e.preventDefault();
e.stopPropagation();
const button = e.currentTarget || this;
const item = button.closest('.model-list-item');
if (!item) return;
const container = item.closest('.model-list-container');
if (!container) return;
const minItems = parseInt(container.dataset.minItems || '0');
const itemsContainer = container.querySelector('.model-list-items');
const currentItems = itemsContainer.querySelectorAll('.model-list-item').length;
if (currentItems <= minItems) {
alert(`Minimum ${minItems} items required.`);
return;
}
// Check if item has data
const hasData = Array.from(item.querySelectorAll('input, select, textarea')).some(input => {
if (input.type === 'checkbox' || input.type === 'radio') {
return input.checked;
}
return input.value && input.value.trim() !== '';
});
if (hasData) {
if (!confirm('Are you sure you want to remove this item? All data will be lost.')) {
return;
}
}
item.remove();
updateItemIndices(itemsContainer);
}
// Update titles when input fields change
document.addEventListener('input', function(e) {
if (e.target.name && (e.target.name.includes('.name') || e.target.name.includes('.relationship'))) {
updateItemTitle(e.target);
}
});
// Handle collapse icons
document.addEventListener('click', function(e) {
const collapseButton = e.target.closest('[data-bs-toggle="collapse"]');
if (collapseButton) {
const icon = collapseButton.querySelector('.bi-chevron-down, .bi-chevron-right');
if (icon) {
setTimeout(() => {
const isExpanded = collapseButton.getAttribute('aria-expanded') === 'true';
icon.className = isExpanded ? 'bi bi-chevron-down me-2' : 'bi bi-chevron-right me-2';
}, 50);
}
}
});
})();
function addNewListItem(fieldName, index) {
const container = document.querySelector(`[data-field-name="${fieldName}"]`);
const itemsContainer = container.querySelector('.model-list-items');
// Get the first item as a template if it exists
const firstItem = itemsContainer.querySelector('.model-list-item');
if (firstItem) {
const newItem = firstItem.cloneNode(true);
// Clear all input values
newItem.querySelectorAll('input, select, textarea').forEach(input => {
if (input.type === 'checkbox' || input.type === 'radio') {
input.checked = false;
} else {
input.value = '';
}
});
// Update data-index
newItem.dataset.index = index;
// Update field names and IDs
updateFieldNames(newItem, fieldName, index);
// Update collapse IDs
updateCollapseIds(newItem, fieldName, index);
// Expand the new item
const collapseDiv = newItem.querySelector('.collapse');
if (collapseDiv) {
collapseDiv.classList.add('show');
}
// Update collapse button aria-expanded
const collapseButton = newItem.querySelector('[data-bs-toggle="collapse"]');
if (collapseButton) {
collapseButton.setAttribute('aria-expanded', 'true');
const icon = collapseButton.querySelector('.bi-chevron-down, .bi-chevron-right');
if (icon) {
icon.className = 'bi bi-chevron-down me-2';
}
}
itemsContainer.appendChild(newItem);
}
}
function updateItemIndices(container) {
const items = container.querySelectorAll('.model-list-item');
items.forEach((item, index) => {
item.dataset.index = index;
// Update field names first
const fieldName = container.closest('.model-list-container').dataset.fieldName;
updateFieldNames(item, fieldName, index);
updateCollapseIds(item, fieldName, index);
// Update title using the dynamic template
updateItemTitleFromData(item, index);
});
}
function updateFieldNames(item, fieldName, index) {
item.querySelectorAll('input, select, textarea').forEach(input => {
if (input.name) {
// Update name attribute to use correct index
input.name = input.name.replace(/\[\d+\]/, `[${index}]`);
}
if (input.id) {
// Update id attribute
input.id = input.id.replace(/\[\d+\]/, `[${index}]`);
}
});
item.querySelectorAll('label').forEach(label => {
if (label.getAttribute('for')) {
label.setAttribute('for', label.getAttribute('for').replace(/\[\d+\]/, `[${index}]`));
}
});
}
function updateCollapseIds(item, fieldName, index) {
const collapseDiv = item.querySelector('.collapse');
const collapseButton = item.querySelector('[data-bs-toggle="collapse"]');
if (collapseDiv && collapseButton) {
const newId = `${fieldName}_item_${index}_content`;
collapseDiv.id = newId;
collapseButton.setAttribute('data-bs-target', `#${newId}`);
collapseButton.setAttribute('aria-controls', newId);
}
}
function updateItemTitle(inputElement) {
const item = inputElement.closest('.model-list-item');
if (!item) return;
updateItemTitleFromData(item);
}
function updateItemTitleFromData(item, forceIndex = null) {
const index = forceIndex !== null ? forceIndex : parseInt(item.dataset.index);
const titleTemplate = item.dataset.titleTemplate || 'Item #{index}';
const titleElement = item.querySelector('h6 button, h6 span');
if (!titleElement) return;
// Extract current form data from the item
const formData = { index: index + 1 };
item.querySelectorAll('input, select, textarea').forEach(input => {
if (input.name) {
// Extract field name (e.g., "pets[0].name" -> "name")
const fieldMatch = input.name.match(/\.([^.]+)$/);
if (fieldMatch) {
const fieldName = fieldMatch[1];
if (input.type === 'checkbox') {
formData[fieldName] = input.checked;
} else {
formData[fieldName] = input.value || '';
}
}
}
});
// Generate title from template
let newTitle;
try {
newTitle = titleTemplate.replace(/\{([^}]+)\}/g, (match, key) => {
return formData[key] || '';
});
} catch (e) {
newTitle = `Item #${index + 1}`;
}
// Update the title while preserving icons
const cardIcon = '<i class="bi bi-card-list me-2"></i>';
if (titleElement.tagName === 'BUTTON') {
const chevronIcon = titleElement.querySelector('.bi-chevron-down, .bi-chevron-right');
const chevronHtml = chevronIcon ? chevronIcon.outerHTML : '<i class="bi bi-chevron-down me-2"></i>';
titleElement.innerHTML = `${chevronHtml}${cardIcon}${newTitle}`;
} else {
titleElement.innerHTML = `${cardIcon}${newTitle}`;
}
}
</script>
class CompleteShowcaseForm(FormModel):
"""
Complete showcase form demonstrating all Pydantic SchemaForms capabilities:
- All input types (text, email, number, select, checkbox, date, color, etc.)
- Collapsible list layouts with cards
- Dynamic titles and field validation
- Icons and help text
- Multiple layout options
"""
# ======== PERSONAL INFORMATION SECTION ========
first_name: str = FormField(
title="First Name",
input_type="text",
placeholder="Enter your first name",
help_text="Your given name as it appears on official documents",
icon="person",
min_length=2,
max_length=50
)
last_name: str = FormField(
title="Last Name",
input_type="text",
placeholder="Enter your last name",
help_text="Your family name or surname",
icon="person",
min_length=2,
max_length=50
)
email: EmailStr = FormField(
title="Email Address",
input_type="email",
placeholder="your.email@example.com",
help_text="We'll use this to contact you about your registration",
icon="envelope"
)
phone: Optional[str] = FormField(
None,
title="Phone Number",
input_type="tel",
placeholder="+1 (555) 123-4567",
help_text="Include country code for international numbers",
icon="telephone",
pattern=r"^[\+]?[1-9][\d]{0,15}$"
)
birth_date: Optional[date] = FormField(
None,
title="Date of Birth",
input_type="date",
help_text="Used to verify age requirements (optional)",
icon="calendar-date"
)
age: Optional[int] = FormField(
None,
title="Age",
input_type="number",
placeholder="25",
help_text="Your current age in years",
icon="hash",
min_value=13,
max_value=120
)
# ======== PREFERENCES SECTION ========
favorite_color: Optional[str] = FormField(
"#3498db",
title="Favorite Color",
input_type="color",
help_text="Pick your favorite color",
icon="palette"
)
experience_level: str = FormField(
title="Experience Level",
input_type="select",
options=[
{"value": "beginner", "label": "π± Beginner (0-1 years)"},
{"value": "intermediate", "label": "π Intermediate (2-5 years)"},
{"value": "advanced", "label": "π― Advanced (5-10 years)"},
{"value": "expert", "label": "π Expert (10+ years)"}
],
help_text="Select your experience level",
icon="trophy"
)
newsletter_subscription: bool = FormField(
True,
title="Subscribe to Newsletter",
input_type="checkbox",
help_text="Receive updates and news about our services",
icon="mailbox"
)
rating: Optional[int] = FormField(
None,
title="Rate Your Interest (1-10)",
input_type="range",
help_text="How interested are you in our services?",
icon="star",
min_value=1,
max_value=10
)
# ======== ADDRESS INFORMATION ========
address: Optional[str] = FormField(
None,
title="Street Address",
input_type="textarea",
placeholder="123 Main Street\nApt 4B",
help_text="Your full mailing address (optional)",
icon="house",
max_length=500
)
country: Optional[Country] = FormField(
None,
title="Country",
input_type="select",
options=[
{"value": "US", "label": "πΊπΈ United States"},
{"value": "CA", "label": "π¨π¦ Canada"},
{"value": "UK", "label": "π¬π§ United Kingdom"},
{"value": "DE", "label": "π©πͺ Germany"},
{"value": "FR", "label": "π«π· France"},
{"value": "AU", "label": "π¦πΊ Australia"},
{"value": "OTHER", "label": "π Other"}
],
help_text="Select your country of residence",
icon="globe"
)
# ======== PETS SECTION (ENHANCED LIST) ========
pets: List[PetModel] = FormField(
default_factory=list,
title="Your Pets",
input_type="model_list",
help_text="Tell us about each of your beloved pets",
icon="heart-fill",
min_length=0,
max_length=5,
model_class=PetModel,
add_button_text="πΎ Add Another Pet",
remove_button_text="Remove Pet",
collapsible_items=True,
items_expanded=False,
item_title_template="πΎ {name} the {species}",
section_design={
"section_title": "Pet Registry",
"section_description": "Register each of your pets with detailed information for our records",
"icon": "bi bi-heart-fill",
"collapsible": True,
"collapsed": False
}
)
# ======== EMERGENCY CONTACTS (ANOTHER LIST) ========
emergency_contacts: List[EmergencyContactModel] = FormField(
default_factory=list,
title="Emergency Contacts",
input_type="model_list",
help_text="Add people we can contact in case of emergency",
icon="person-exclamation",
min_length=1,
max_length=3,
model_class=EmergencyContactModel,
add_button_text="β Add Emergency Contact",
remove_button_text="Remove Contact",
collapsible_items=True,
items_expanded=True,
item_title_template="π {name} ({relationship})",
section_design={
"section_title": "Emergency Contacts",
"section_description": "At least one emergency contact is required",
"icon": "bi bi-shield-exclamation",
"collapsible": False,
"collapsed": False
}
)
# ======== ADDITIONAL PREFERENCES ========
special_requests: Optional[str] = FormField(
None,
title="Special Requests or Comments",
input_type="textarea",
placeholder="Any special requests, dietary restrictions, accessibility needs, or additional comments...",
help_text="Let us know about any special accommodations you need",
icon="chat-dots",
max_length=1000
)
terms_accepted: bool = FormField(
False,
title="I accept the Terms and Conditions",
input_type="checkbox",
help_text="You must accept the terms to proceed",
icon="check-square"
)
@field_validator('terms_accepted')
@classmethod
def validate_terms(cls, v):
if not v:
raise ValueError('You must accept the terms and conditions')
return v
{
"$defs": {
"Country": {
"description": "Countries for selection.",
"enum": [
"United States",
"Canada",
"United Kingdom",
"Australia",
"Germany",
"France",
"Japan"
],
"title": "Country",
"type": "string"
},
"EmergencyContactModel": {
"description": "Emergency contact information model.",
"properties": {
"name": {
"autofocus": false,
"description": "Full name of emergency contact",
"disabled": false,
"help_text": "Full name of emergency contact",
"icon": "person-badge",
"input_type": "text",
"maxLength": 100,
"minLength": 2,
"placeholder": "John Doe",
"readonly": false,
"title": "Contact Name",
"type": "string"
},
"relationship": {
"autofocus": false,
"description": "Your relationship to this person",
"disabled": false,
"help_text": "Your relationship to this person",
"icon": "people",
"input_type": "select",
"options": [
{
"label": "\ud83d\udc91 Spouse/Partner",
"value": "spouse"
},
{
"label": "\ud83d\udc68\u200d\ud83d\udc69\u200d\ud83d\udc67\u200d\ud83d\udc66 Parent",
"value": "parent"
},
{
"label": "\ud83d\udc76 Child",
"value": "child"
},
{
"label": "\ud83d\udc6b Sibling",
"value": "sibling"
},
{
"label": "\ud83d\udc65 Friend",
"value": "friend"
},
{
"label": "\ud83d\udcbc Colleague",
"value": "colleague"
},
{
"label": "\ud83e\udd1d Other",
"value": "other"
}
],
"readonly": false,
"title": "Relationship",
"type": "string"
},
"phone": {
"autofocus": false,
"description": "Primary phone number for this contact",
"disabled": false,
"help_text": "Primary phone number for this contact",
"icon": "telephone",
"input_type": "tel",
"maxLength": 20,
"minLength": 10,
"placeholder": "+1 (555) 123-4567",
"readonly": false,
"title": "Phone Number",
"type": "string"
},
"email": {
"anyOf": [
{
"format": "email",
"type": "string"
},
{
"type": "null"
}
],
"autofocus": false,
"default": null,
"description": "Email address (optional)",
"disabled": false,
"help_text": "Email address (optional)",
"icon": "envelope",
"input_type": "email",
"placeholder": "contact@example.com",
"readonly": false,
"title": "Email Address"
},
"available_24_7": {
"autofocus": false,
"default": false,
"description": "Can this person be contacted at any time?",
"disabled": false,
"help_text": "Can this person be contacted at any time?",
"icon": "clock",
"input_type": "checkbox",
"readonly": false,
"title": "Available 24/7",
"type": "boolean"
}
},
"required": [
"name",
"relationship",
"phone"
],
"title": "EmergencyContactModel",
"type": "object"
},
"PetModel": {
"description": "Enhanced pet information model showcasing various input types.",
"properties": {
"name": {
"autofocus": false,
"description": "The name of your pet",
"disabled": false,
"help_text": "The name of your pet",
"icon": "heart",
"input_type": "text",
"maxLength": 50,
"minLength": 1,
"placeholder": "Enter your pet's name",
"readonly": false,
"title": "Pet's Name",
"type": "string"
},
"species": {
"autofocus": false,
"description": "What type of animal is your pet?",
"disabled": false,
"help_text": "What type of animal is your pet?",
"icon": "collection",
"input_type": "select",
"options": [
{
"label": "Dog \ud83d\udc15",
"value": "Dog"
},
{
"label": "Cat \ud83d\udc31",
"value": "Cat"
},
{
"label": "Bird \ud83d\udc26",
"value": "Bird"
},
{
"label": "Fish \ud83d\udc20",
"value": "Fish"
},
{
"label": "Rabbit \ud83d\udc30",
"value": "Rabbit"
},
{
"label": "Hamster \ud83d\udc39",
"value": "Hamster"
},
{
"label": "Reptile \ud83e\udd8e",
"value": "Reptile"
},
{
"label": "Other \ud83d\udc3e",
"value": "Other"
}
],
"readonly": false,
"title": "Species",
"type": "string"
},
"age": {
"anyOf": [
{
"maximum": 50,
"minimum": 0,
"type": "integer"
},
{
"type": "null"
}
],
"autofocus": false,
"default": null,
"description": "How old is your pet? (optional)",
"disabled": false,
"help_text": "How old is your pet? (optional)",
"icon": "calendar",
"input_type": "number",
"placeholder": "Pet's age in years",
"readonly": false,
"title": "Age"
},
"weight": {
"anyOf": [
{
"maximum": 500.0,
"minimum": 0.01,
"type": "number"
},
{
"type": "null"
}
],
"autofocus": false,
"default": null,
"description": "Weight in pounds (optional - enter 0.01 for tiny pets like birds)",
"disabled": false,
"help_text": "Weight in pounds (optional - enter 0.01 for tiny pets like birds)",
"icon": "speedometer2",
"input_type": "number",
"placeholder": "Pet's weight",
"readonly": false,
"title": "Weight (lbs)"
},
"is_vaccinated": {
"autofocus": false,
"default": false,
"description": "Is your pet up to date with vaccinations?",
"disabled": false,
"help_text": "Is your pet up to date with vaccinations?",
"icon": "shield-check",
"input_type": "checkbox",
"readonly": false,
"title": "Vaccinated",
"type": "boolean"
},
"microchipped": {
"autofocus": false,
"default": false,
"description": "Does your pet have a microchip?",
"disabled": false,
"help_text": "Does your pet have a microchip?",
"icon": "cpu",
"input_type": "checkbox",
"readonly": false,
"title": "Microchipped",
"type": "boolean"
},
"breed": {
"anyOf": [
{
"maxLength": 100,
"type": "string"
},
{
"type": "null"
}
],
"autofocus": false,
"default": null,
"description": "Specific breed of your pet (optional)",
"disabled": false,
"help_text": "Specific breed of your pet (optional)",
"icon": "award",
"input_type": "text",
"placeholder": "e.g., Golden Retriever, Persian Cat",
"readonly": false,
"title": "Breed"
},
"color": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"autofocus": false,
"default": null,
"description": "Primary color of your pet (optional)",
"disabled": false,
"help_text": "Primary color of your pet (optional)",
"icon": "palette",
"input_type": "color",
"readonly": false,
"title": "Primary Color"
},
"last_vet_visit": {
"anyOf": [
{
"format": "date",
"type": "string"
},
{
"type": "null"
}
],
"autofocus": false,
"default": null,
"description": "When was the last veterinary checkup? (optional)",
"disabled": false,
"help_text": "When was the last veterinary checkup? (optional)",
"icon": "calendar-date",
"input_type": "date",
"readonly": false,
"title": "Last Vet Visit"
},
"special_needs": {
"anyOf": [
{
"maxLength": 500,
"type": "string"
},
{
"type": "null"
}
],
"autofocus": false,
"default": null,
"description": "Describe any special care requirements (optional)",
"disabled": false,
"help_text": "Describe any special care requirements (optional)",
"icon": "heart-pulse",
"input_type": "textarea",
"placeholder": "Any special care requirements, medications, allergies, etc.",
"readonly": false,
"title": "Special Needs"
}
},
"required": [
"name",
"species"
],
"title": "PetModel",
"type": "object"
}
},
"description": "Complete showcase form demonstrating all Pydantic SchemaForms capabilities:\n- All input types (text, email, number, select, checkbox, date, color, etc.)\n- Collapsible list layouts with cards\n- Dynamic titles and field validation\n- Icons and help text\n- Multiple layout options",
"properties": {
"first_name": {
"autofocus": false,
"description": "Your given name as it appears on official documents",
"disabled": false,
"help_text": "Your given name as it appears on official documents",
"icon": "person",
"input_type": "text",
"maxLength": 50,
"minLength": 2,
"placeholder": "Enter your first name",
"readonly": false,
"title": "First Name",
"type": "string"
},
"last_name": {
"autofocus": false,
"description": "Your family name or surname",
"disabled": false,
"help_text": "Your family name or surname",
"icon": "person",
"input_type": "text",
"maxLength": 50,
"minLength": 2,
"placeholder": "Enter your last name",
"readonly": false,
"title": "Last Name",
"type": "string"
},
"email": {
"autofocus": false,
"description": "We'll use this to contact you about your registration",
"disabled": false,
"format": "email",
"help_text": "We'll use this to contact you about your registration",
"icon": "envelope",
"input_type": "email",
"placeholder": "your.email@example.com",
"readonly": false,
"title": "Email Address",
"type": "string"
},
"phone": {
"anyOf": [
{
"pattern": "^[\\+]?[1-9][\\d]{0,15}$",
"type": "string"
},
{
"type": "null"
}
],
"autofocus": false,
"default": null,
"description": "Include country code for international numbers",
"disabled": false,
"help_text": "Include country code for international numbers",
"icon": "telephone",
"input_type": "tel",
"placeholder": "+1 (555) 123-4567",
"readonly": false,
"title": "Phone Number"
},
"birth_date": {
"anyOf": [
{
"format": "date",
"type": "string"
},
{
"type": "null"
}
],
"autofocus": false,
"default": null,
"description": "Used to verify age requirements (optional)",
"disabled": false,
"help_text": "Used to verify age requirements (optional)",
"icon": "calendar-date",
"input_type": "date",
"readonly": false,
"title": "Date of Birth"
},
"age": {
"anyOf": [
{
"maximum": 120,
"minimum": 13,
"type": "integer"
},
{
"type": "null"
}
],
"autofocus": false,
"default": null,
"description": "Your current age in years",
"disabled": false,
"help_text": "Your current age in years",
"icon": "hash",
"input_type": "number",
"placeholder": "25",
"readonly": false,
"title": "Age"
},
"favorite_color": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"autofocus": false,
"default": "#3498db",
"description": "Pick your favorite color",
"disabled": false,
"help_text": "Pick your favorite color",
"icon": "palette",
"input_type": "color",
"readonly": false,
"title": "Favorite Color"
},
"experience_level": {
"autofocus": false,
"description": "Select your experience level",
"disabled": false,
"help_text": "Select your experience level",
"icon": "trophy",
"input_type": "select",
"options": [
{
"label": "\ud83c\udf31 Beginner (0-1 years)",
"value": "beginner"
},
{
"label": "\ud83d\ude80 Intermediate (2-5 years)",
"value": "intermediate"
},
{
"label": "\ud83c\udfaf Advanced (5-10 years)",
"value": "advanced"
},
{
"label": "\ud83c\udfc6 Expert (10+ years)",
"value": "expert"
}
],
"readonly": false,
"title": "Experience Level",
"type": "string"
},
"newsletter_subscription": {
"autofocus": false,
"default": true,
"description": "Receive updates and news about our services",
"disabled": false,
"help_text": "Receive updates and news about our services",
"icon": "mailbox",
"input_type": "checkbox",
"readonly": false,
"title": "Subscribe to Newsletter",
"type": "boolean"
},
"rating": {
"anyOf": [
{
"maximum": 10,
"minimum": 1,
"type": "integer"
},
{
"type": "null"
}
],
"autofocus": false,
"default": null,
"description": "How interested are you in our services?",
"disabled": false,
"help_text": "How interested are you in our services?",
"icon": "star",
"input_type": "range",
"readonly": false,
"title": "Rate Your Interest (1-10)"
},
"address": {
"anyOf": [
{
"maxLength": 500,
"type": "string"
},
{
"type": "null"
}
],
"autofocus": false,
"default": null,
"description": "Your full mailing address (optional)",
"disabled": false,
"help_text": "Your full mailing address (optional)",
"icon": "house",
"input_type": "textarea",
"placeholder": "123 Main Street\nApt 4B",
"readonly": false,
"title": "Street Address"
},
"country": {
"anyOf": [
{
"$ref": "#/$defs/Country"
},
{
"type": "null"
}
],
"autofocus": false,
"default": null,
"description": "Select your country of residence",
"disabled": false,
"help_text": "Select your country of residence",
"icon": "globe",
"input_type": "select",
"options": [
{
"label": "\ud83c\uddfa\ud83c\uddf8 United States",
"value": "US"
},
{
"label": "\ud83c\udde8\ud83c\udde6 Canada",
"value": "CA"
},
{
"label": "\ud83c\uddec\ud83c\udde7 United Kingdom",
"value": "UK"
},
{
"label": "\ud83c\udde9\ud83c\uddea Germany",
"value": "DE"
},
{
"label": "\ud83c\uddeb\ud83c\uddf7 France",
"value": "FR"
},
{
"label": "\ud83c\udde6\ud83c\uddfa Australia",
"value": "AU"
},
{
"label": "\ud83c\udf0d Other",
"value": "OTHER"
}
],
"readonly": false,
"title": "Country"
},
"pets": {
"add_button_text": "\ud83d\udc3e Add Another Pet",
"autofocus": false,
"collapsible_items": true,
"default_factory": "builtins.list",
"description": "Tell us about each of your beloved pets",
"disabled": false,
"help_text": "Tell us about each of your beloved pets",
"icon": "heart-fill",
"input_type": "model_list",
"item_title_template": "\ud83d\udc3e {name} the {species}",
"items": {
"$ref": "#/$defs/PetModel"
},
"items_expanded": false,
"maxItems": 5,
"minItems": 0,
"model_class": "src.models.PetModel",
"readonly": false,
"remove_button_text": "Remove Pet",
"section_design": {
"collapsed": false,
"collapsible": true,
"icon": "bi bi-heart-fill",
"section_description": "Register each of your pets with detailed information for our records",
"section_title": "Pet Registry"
},
"title": "Your Pets",
"type": "array"
},
"emergency_contacts": {
"add_button_text": "\u2795 Add Emergency Contact",
"autofocus": false,
"collapsible_items": true,
"default_factory": "builtins.list",
"description": "Add people we can contact in case of emergency",
"disabled": false,
"help_text": "Add people we can contact in case of emergency",
"icon": "person-exclamation",
"input_type": "model_list",
"item_title_template": "\ud83d\udcde {name} ({relationship})",
"items": {
"$ref": "#/$defs/EmergencyContactModel"
},
"items_expanded": true,
"maxItems": 3,
"minItems": 1,
"model_class": "src.models.EmergencyContactModel",
"readonly": false,
"remove_button_text": "Remove Contact",
"section_design": {
"collapsed": false,
"collapsible": false,
"icon": "bi bi-shield-exclamation",
"section_description": "At least one emergency contact is required",
"section_title": "Emergency Contacts"
},
"title": "Emergency Contacts",
"type": "array"
},
"special_requests": {
"anyOf": [
{
"maxLength": 1000,
"type": "string"
},
{
"type": "null"
}
],
"autofocus": false,
"default": null,
"description": "Let us know about any special accommodations you need",
"disabled": false,
"help_text": "Let us know about any special accommodations you need",
"icon": "chat-dots",
"input_type": "textarea",
"placeholder": "Any special requests, dietary restrictions, accessibility needs, or additional comments...",
"readonly": false,
"title": "Special Requests or Comments"
},
"terms_accepted": {
"autofocus": false,
"default": false,
"description": "You must accept the terms to proceed",
"disabled": false,
"help_text": "You must accept the terms to proceed",
"icon": "check-square",
"input_type": "checkbox",
"readonly": false,
"title": "I accept the Terms and Conditions",
"type": "boolean"
}
},
"required": [
"first_name",
"last_name",
"email",
"experience_level",
"pets",
"emergency_contacts"
],
"title": "CompleteShowcaseForm",
"type": "object"
}{
"first_name": {
"required": true,
"type": "string",
"minLength": 2,
"maxLength": 50
},
"last_name": {
"required": true,
"type": "string",
"minLength": 2,
"maxLength": 50
},
"email": {
"required": true,
"type": "string",
"format": "email"
},
"phone": {
"required": false
},
"birth_date": {
"required": false
},
"age": {
"required": false
},
"favorite_color": {
"required": false
},
"experience_level": {
"required": true,
"type": "string"
},
"newsletter_subscription": {
"required": false,
"type": "boolean"
},
"rating": {
"required": false
},
"address": {
"required": false
},
"country": {
"required": false
},
"pets": {
"required": true,
"type": "array"
},
"emergency_contacts": {
"required": true,
"type": "array"
},
"special_requests": {
"required": false
},
"terms_accepted": {
"required": false,
"type": "boolean"
}
}{
"errors": {},
"data": {
"first_name": "Alex",
"last_name": "Johnson",
"email": "alex.johnson@example.com",
"phone": "+1 (555) 234-5678",
"birth_date": "1995-06-15",
"age": 28,
"favorite_color": "#3498db",
"experience_level": "intermediate",
"newsletter_subscription": true,
"rating": 8,
"address": "456 Oak Avenue\nUnit 12\nDowntown District",
"country": "US",
"pets": [
{
"name": "Buddy",
"species": "dog",
"breed": "Labrador",
"age": 4,
"weight": 70.0,
"microchipped": true,
"vaccination_date": "2024-03-10",
"special_needs": "Needs hip medication twice daily"
},
{
"name": "Whiskers",
"species": "cat",
"breed": "Maine Coon",
"age": 5,
"weight": 12.5,
"microchipped": true,
"vaccination_date": "2024-04-05",
"special_needs": "Requires grain-free diet"
}
],
"emergency_contacts": [
{
"name": "Emma Johnson",
"relationship": "spouse",
"phone": "+1 (555) 345-6789",
"email": "emma.johnson@example.com",
"available_24_7": true
},
{
"name": "Robert Johnson",
"relationship": "parent",
"phone": "+1 (555) 456-7890",
"email": "robert.johnson@example.com",
"available_24_7": false
}
],
"special_requests": "Please contact me via email for all communications. I work night shifts and may not be available by phone during the day.",
"terms_accepted": true
}
}