Skip to content

2.0.20: Add key/value editor for multi-choice custom-field options

Choose a tag to compare

@gp247net gp247net released this 14 Aug 10:30
· 26 commits to master since this release
Multi-choice option types (select/radio/checkbox) previously required
admins to hand-type the raw JSON object ({"value":"label"}) into a
single text input. Replace it with a reusable <x-gp247::key-value-editor>
table (Value / Label columns, add & remove rows) that serialises to the
same JSON contract, so nothing downstream (storefront renderer,
gp247_custom_field_rules) changes. Scalar option types keep the plain
default input.

The component uses an inline x-data object literal rather than an
@assets Alpine.data factory: it is rendered conditionally, and a
<script> injected during a Livewire re-render does not execute (scripts
set via innerHTML do not run), which left x-data undefined and the table
empty. Inline x-data has no external-script dependency and initialises
whether present at page load or injected on re-render.

Validate form.default defensively for list types (non-empty object,
non-empty unique keys) and cap at max:250 to mirror the DB column. Add
en/vi language keys for the editor labels and validation messages.

@aidlc-unit admin-shell
@aidlc-story US-UI-007

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>