Hello @infraroth
The plugin allows you to fill controls in the form with information stored in data sources, like a database, CSV file, JSON structures, and others.
For example, if you want to fill in a dropdown field with the users’ names as its choices texts and their emails as the choices’ values, you can enter the following tags on your form:
<label> Users list
[select users-emails] </label>
<template id="user_name">{attribute.first_name} {attribute.last_name}</template>
[cf7-recordset id="users-records" type="user" attributes="user_email, first_name, last_name"]
[cf7-link-field recordset="users-records" field="users-emails" value="user_email" text="{template.user_name}"]
Best regards.
Thanks for your quick reply! The problem with this is that the email can be read by spammers, hence the “|” feature provided by CF7.
-
This reply was modified 3 years, 5 months ago by
infraroth.
Hello @infraroth
To replace the @ symbol by |, you can use callbacks:
<label> Users list
[select users-emails] </label>
<script> function preprocess(records){for(var i in records){ records[i]['user_name'] = records[i]['first_name']+' '+records[i]['last_name']; records[i]['user_email'] = records[i]['user_email'].replace('@', '|');} return records;}</script>
[cf7-recordset id="users-records" type="user" attributes="user_email, first_name, last_name" callback="preprocess"]
[cf7-link-field recordset="users-records" field="users-emails" value="user_email" text="user_name"]
Best regards.