mirror of
https://github.com/ChuckBuilds/LEDMatrix.git
synced 2026-04-11 05:13:01 +00:00
fix: Use indexed names for checkbox-group to work with existing parser
Change checkbox-group widget to use indexed field names instead of bracket
notation, so the existing indexed field parser correctly handles multiple
selected values.
Problem:
- checkbox-group uses name="{{ full_key }}[]" which requires bracket
notation handling in backend
- While bracket notation handler exists, using indexed names is more robust
and leverages existing well-tested indexed field parser
- Indexed field parser already handles fields like "field_name.0",
"field_name.1" correctly
Solution:
- Template: Change name="{{ full_key }}[]" to name="{{ full_key }}.{{
loop.index0 }}"
- JavaScript: Update checkbox-group rendering to use name="."
- Backend indexed field parser (lines 3364-3388) already handles this pattern:
- Detects fields ending with numeric indices (e.g., ".0", ".1")
- Groups them by base_path and sorts by index
- Combines into array correctly
This ensures checkbox-group values are properly preserved when multiple
options are selected, working with the existing schema-based parsing system.
This commit is contained in:
@@ -3002,7 +3002,7 @@ function generateFieldHtml(key, prop, value, prefix = '') {
|
||||
const labels = xOptions.labels || {};
|
||||
|
||||
html += `<div class="mt-1 space-y-2">`;
|
||||
enumItems.forEach(option => {
|
||||
enumItems.forEach((option, index) => {
|
||||
const isChecked = arrayValue.includes(option);
|
||||
const label = labels[option] || option.replace(/_/g, ' ').replace(/\b\w/g, l => l.toUpperCase());
|
||||
const checkboxId = `${fullKey.replace(/\./g, '_')}_${option}`;
|
||||
@@ -3010,7 +3010,7 @@ function generateFieldHtml(key, prop, value, prefix = '') {
|
||||
<label class="flex items-center">
|
||||
<input type="checkbox"
|
||||
id="${checkboxId}"
|
||||
name="${fullKey}[]"
|
||||
name="${fullKey}.${index}"
|
||||
value="${option}"
|
||||
${isChecked ? 'checked' : ''}
|
||||
class="h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 rounded">
|
||||
|
||||
Reference in New Issue
Block a user