Description
Injects Number fields into matching Image Choice cards server-side so each image can collect a quantity without leaving the card layout. Supports multiple image-choice → quantity mappings per form. Configure a list of forms, each with one or more field mappings that pair an Image Choice field ID with a choice_N → Number field ID lookup.
Usage Notes
- Form setup: Add an Image Choice field and one Number field per image card. Note the form ID, Image Choice field ID, and each Number field ID from the form editor.
- Configuration: Edit
$gf_image_choice_quantities. Each entry is one form. Underfield_mappings, add one entry per Image Choice field.quantitiesmapschoice_N(the last segment of the rendered card class) to a Number field ID. - Choice numbers: Copy the last segment of the rendered card class, e.g.
gchoice_12_3_2is form 12, Image Choice 3, choice 2. Select One (default) starts at 0. Select Multiple starts at 1 and skips values ending in 0 (1-9, then 11, 12, …). - Server-side injection: The Number field’s natural container is suppressed via
gform_field_container_{form}_{field}and re-rendered inside the choice viaGF_Field::get_field_content(). No FOUC. - Submission: The rendered input keeps its native name and ID, so form submission and validation are unchanged.
- Conditional logic: The injected wrapper reuses the
field_{form}_{field}ID, so conditional logic targeting the Number field still shows/hides it (now inside the choice). - Click targets: Nested field markup inside
.gchoicecan bubble clicks to the image choice input. A form-specific init script stops propagation on each quantity input so editing does not toggle the choice.
Code
Please log in to view this code snippet.