Multi-select (child table)

IngredientformIngredients

Provide a multiselect dropdown for populating a child table

Ingredient Family: formIngredients

Outline Display: A multi-select dropdown for a related table connected to {{childTable}}.
The column in the child that references the parent is {{childTableParentRef}}.
The column for the dropdown is {{childTableDropdownColumn}}, and we populate the dropdown with {{query}}.
{{childForm:For any other fields, we use the subform defined by: {{childForm}}}}

Requirements

The query SQL query must return exactly 2 columns: (1) A Value column with values compatible with the dropdown column type. (2) A Label column with the text to show in the dropdown. CORRECT PATTERN: SELECT “RefTable”.“Id” AS “Value”, “RefTable”.“Name” AS “Label” FROM “RefTable” ORDER BY “RefTable”.“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:

  • parentTable – repeat of $parentTable
  • childTable – table chosen from the app’s schema (via childTable knob)
  • queryTab – result columns of query (referenceable as a virtual table)
  • $formFieldsTable – renamed copy of $formFieldsTable
  • $parentTable – repeat of childTable

Settings

Required

  • childTable : table
    The table which we would like the form to be able to add rows to

  • childTableParentRef : column of childTable (type filter: any type (must be required))
    The column in the child that references the parent

  • childTableDropdownColumn : column of childTable (type filter: any type)
    The column on which to sort the child table rows

  • query : SQL query
    A SQL query returning the values for the multi-select dropdown.
    Must produce: result named Value matching any type, then result named Label matching showable 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).

  • 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])

  • ref : new column (type: text; required, non-nullable)
    ref

Optional

  • shouldShow : formula (returns bool; required, non-nullable)
    Should we show this embedded form? If the formula yields True, it is shown and used. Otherwise, it is as if the user left the embedded forms blank.
    Scope: all columns of $formFieldsTable (reference as [ColumnName], e.g., [Name], [Price])

  • 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.

  • maxSelections : formula (returns integer; required, non-nullable)
    Max # of selections the user is allowed to make (0 for unlimited)
    Scope: all columns of $formFieldsTable (reference as [ColumnName], e.g., [Name], [Price])

  • cssWidth : constant value (type: integer; required, non-nullable)
    Width of this widget, between 1 and 12 (12 means a full row of the form)

  • childForm : ingredient slot of formIngredients($parentTable, $formFieldsTable) (many)
    Descriptions for widgets or other ways of asking the user for information to construct a row in the other table. Note that the order of the ingredients will be reflected in the order of the form and that there must be an ingredient to produce each column in the other table except for the columns: [childTableParentRef], [childTableDropdownColumn]. Key columns should use SequentialID.