Examples of using data sources include:
- Populating a select field with U.S. states.
- Populating checkboxes that represent post tags or categories.
- Populating radio buttons for selecting a user.
- Populating a select field with options from an ACF, Meta Box, Pods or Toolset choice field.
- Populating a select field with data returned from a PHP filter hook.
You’ll find the data source option at top of all field data grids.
By default, the data source will be Off. The Off setting allows you to manually edit the data grid to control which items appear in your field.
Here’s how to use a data source:
1. Select Data Source
- Click the settings icon of the field you want to use a data source with.
- Click on the right most tab in the sidebar (e.g. for a Select field this is called Options)
- Use the Data Source setting to select a data source.
The following data sources can be selected:
Choose from over 25 categorized data sources such as a list of countries or US states.
List posts, pages or any other custom post types.
List terms from any taxonomy, also referred to as categories and tags in WordPress.
List users filtered by role.
- WordPress Filter Hook (Learn More)
Populate data grids using your own custom PHP code.
- ACF Field Options (Advanced Custom Fields plugin)
Pull choices from ACF fields such as select and checkbox fields.
- Meta Box Field Options (Meta Box plugin)
Pull choices from Meta Box fields such as select and checkbox fields.
- Pods Field Options (Pods plugin)
Pull choices from Pods relation fields.
- Toolset Field Options (Toolset plugin)
Pull choices from Tools relation fields.
Once you have selected a data source, the settings for that data source will be displayed.
2. Configure The Data Source
Each data source has its own settings. The Preset data source simply requires that you choose a preset. Other data sources such as Post have many more options that allow you to control and filter the data retrieved.
3. Get Data
Once you have configured the data source, you need to retrieve the data. To do this simply click on the Get Data button.
Once the data is retrieved it will be displayed in a preview data grid:
In the above example, we retrieved a list of countries using the Preset data source. Because this data is static, WS Form will change the Data Source dropdown to Off and then allows you to edit the data grid. Other data sources such as Post or Term are not editable because they update dynamically according to the posts or terms you have created in WordPress.
WS Form updates data sources in real-time. This means that if you create a select field that lists all users, it will keep that list up to date with all the users you have in your WordPress admin. Likewise if you create a field that lists all of your posts, it will keep that list up to date with all the posts you create.
It is possible to make any data source static and no-longer update automatically by choosing Off as the Data Source . Note that when Off is selected, the data grid will not update automatically if the original source data is changed.
4. Column Mapping (Optional)
Once you are happy with the data you have retrieved you should ensure your column mapping is correct. The column mapping settings are shown underneath the data grid.
There are three column mappings to consider:
Choose which column is used as the label shown to the user on the form.
Choose which column is used as the value stored when a choice is made by the user.
- Action Variables
Choose which column is used for displaying a users choice in email notifications and other add-ons or actions.
By default, WS Form will use the first column for each of these settings.
Each time you retrieve new data you should ensure the column mappings are correct.
Click Save & Close (or Save if you wish to make further edits) to save your data source settings.
Click the Preview button at the top of the layout editor to preview the form and test the field contain your data source settings.