Multi-select dropdown menu from query

IngredientformIngredients

A dropdown of options (such that multiple can be selected) based on a SQL query

Ingredient Family: formIngredients

Outline Display: A multiselect dropdown widget for {{columnName}} that draws from {{query}}.

Requirements

The query SQL query must return exactly 2 columns: (1) A Value column with the values to use (should not be NULL). (2) A Label column with the text to show in the dropdown. Use DISTINCT or GROUP BY to avoid duplicates. CORRECT PATTERNS: For foreign key dropdown: SELECT “RefTable”.“KeyColumn” AS “Value”, “RefTable”.“DisplayName” AS “Label” FROM “RefTable” ORDER BY “RefTable”.“DisplayName”. For string dropdown: SELECT “Table”.“Code” AS “Value”, “Table”.“Name” AS “Label” FROM “Table” WHERE “Table”.“Active” = TRUE ORDER BY “Table”.“Name”.

Local scope

The parent slot binds these (look up the slot in the parent to see how):

  • $parentTable – The table (if any) that this form is based on
  • $formFieldsTable – A table of form fields that is built up through the sequence of form ingredients

Names introduced within this component’s knobs:

  • queryTab – result columns of query (referenceable as a virtual table)

Settings

Required

  • columnName : column of $parentTable or new (type filter: any type)
    The column for the dropdown
    Set ty only when columnName names a new column (not in $parentTable).

  • query : SQL query
    A SQL query returning the values for the dropdown.
    Must produce: result named Value matching any type, then result named Label matching any type, then no more results
    Scope: current username as [Username] (only where the handler authenticates: a logged-in page, or the calling user of an MCP tool, including inside its pipeline), all columns of $formFieldsTable (reference as [ColumnName], e.g., [Name], [Price]).

  • required : formula (returns bool; required, non-nullable)
    whether it is required to select at least one item
    Scope: all columns of $formFieldsTable (reference as [ColumnName], e.g., [Name], [Price])

Optional

  • customLabel : formula (returns text; optional)
    A custom label for the dropdown (leaving this empty uses the column name as the label)
    Scope: none – this formula does not accept column references or handler params.

  • cssWidth : constant value (type: integer; required, non-nullable)
    Width between 1 and 12