Choices from a data table
4 min read
A connection can fill the options of a choice field of another form plugin from a data table, so the list (cities, products, branches, teachers) is edited in one place and stays current on every form, without editing the form.
This page belongs to Connections to other form plugins.
What it does
For each bound field the form plugin shows the table's rows as the field's options:
- the label the visitor sees comes from one column, the value that is submitted from another (or the same);
- the options are read when the form is shown and again when it is submitted, so both sides see the same list;
- when a visitor submits a value that is not in the list, the form plugin refuses it with Choose one of the listed options. (optional, see Only accept listed values).
It works for dropdown (select), radio and checkbox fields, in Contact Form 7, Gravity Forms, WPForms and Fluent Forms. In Contact Form 7 an option whose value contains a vertical bar | is left out (CF7 reads label|value pairs).
A connection may do only this: turn Store submissions in a data table off and add choices.
Set it up
- Make the columns public: open the table, Settings tab, tick the label and value columns under Public columns. Only public columns can be used (see Create a data table).
- Open the connection (or Add connection) and choose the plugin and the form.
- In Fill choices from data tables ("The options of a dropdown, radio or checkbox field are read from a data table, so they stay current without editing the form.") click Add choice field. You can add up to 20 bindings per connection, one per field.
- For each binding set:
Setting | Meaning |
|---|---|
Form field | The dropdown, radio or checkbox field to fill. |
Data table | The table to read. |
Label column | The column shown to the visitor. Must be public. |
Value column | The column submitted. Same as label by default. Must be public. |
Filter | Optional. |
Order | A-Z or Z-A, by the label column. |
Limit | How many options, from 1 to 500 (default 100). |
Only accept listed values | On by default: "Submissions with a value that is not in the list are refused." |
- Click Remove on a binding to drop it. Click Create connection / Save changes.
If a column is not public the row says "This column is not public. Make it public in Data Tables or choose another." and links to Make columns public in Data Tables. A table without public columns says "This data table has no public columns yet."
Messages when saving: "Choices of field "city": choose an existing data table." and "Choices of field "city": label and value must be public columns (Data Tables › Settings)." and "Choices of field "city": every filter needs a public column and a known operator."
Behaviour to know
- Options are unique by value (the first row wins), empty values are skipped, HTML is stripped from labels, and at most 500 options are read.
- The list is cached for up to an hour and refreshed at once whenever the table changes (an edit, an import, a sync).
- If the source cannot be used (the plan has no data tables, the table was deleted, a label or value column is no longer public, or a filter names a column that is no longer public) there is no list: the form keeps the choices you typed in the form plugin and nothing is refused. This also prevents a filter from silently widening the list.
- Rows are never shown beyond the public columns, so the form plugin never sees private data of the table.
- The check "Only accept listed values" runs through the form plugin's own validation, so the visitor gets an ordinary field error.
- The table cannot be deleted while a connection reads it.
Example
A table branches with columns Name (name), Code (code) and Open (open, True / false), all three public. In a Contact Form 7 form with [select branch] bind Form field branch to branches, Label column name, Value column code, Filter open:eq:1, Order A-Z. The visitor sees the names of the open branches; the submission carries the code; a tampered value like zzz is refused.
Still stuck? Contact support