Tassos Marinos Developer of Joomla Extensions

Copy Value From One Field to Another

Published in Convert Forms
Updated 04 Dec, 2023

Efficiency in form management is crucial, and the "Copy Value From" functionality in Convert Forms is your key to streamlined data handling. Transferring field values enables you to enhance user interactions, ensuring a more dynamic and personalized form-filling experience. This feature simplifies complex data workflows, saving users valuable time and optimizing the overall efficiency of your form-building process with your Joomla contact form.

Table of Contents

How it Works

Before diving into the magic of field value copying, ensure your setup aligns with the prerequisites:

  • Convert Forms Pro
  • The Conditional Fields plugin must be installed and enabled.
  • A Javascript-enabled browser.

We need to set up conditions in the Conditional Fields section to copy field values in Convert Forms.

Copying One Field to Another Field

This example demonstrates the base functionality. Our form has two textboxes: "Favorite Word” and “Auto-copied word”. Whenever someone fills in the “Favorite Word” field, we want to copy its value to the “Auto-copied Word”.

To do so, open up Conditional Fields.

  1. Click “Add condition”.
  2. Select the field “Word” in the 1st dropdown.
  3. Select the “Updates” comparison operator in the 2nd dropdown.

Next, in the “Do” section

  1. Select “Favorite Word” as the target field in the 1st dropdown.
  2. Select the “Copy Value Form” action in the 2nd dropdown.
  3. Select the field “Word” as the value in the 3rd dropdown.

The settings of our condition will look like this:

Copying Multiple Field Values Conditionally

The preceding example illustrated how to copy field values when the source field changes.

However, there are instances where we want to copy values only under specific conditions, such as when a checkbox is clicked and checked.

To accomplish this, rather than relying on the "Updates" comparison operator that triggers whenever the field value changes, we employ other operators that compare the field value against specified criteria.

For example, to copy a field value only when a checkbox is checked, utilize the "Is Checked" operator. This ensures the copying action is contingent upon fulfilling the specified condition.

The settings of our condition will look like this:

To learn more about setting conditions, visit How to Setup Conditional Fields doc.

Copying Field Value with Custom Formulas

The "Copy Value From" action allows us to choose a single field. However, there are scenarios where simply copying the field value falls short. What if we need to copy multiple field values or add custom text, such as a prefix or suffix, to the field value? We can achieve this by employing the "Change Value" action with the Smart Tag {field.NAME}.

Let's delve into some examples.

Concatenating Multiple Field Values Into One Field

Imagine our form includes fields like First Name, Last Name, and Full Name. We want to automatically combine the values of First Name and Last Name into the Full Name whenever someone updates them. For instance, entering "John" and "Doe" in the First Name and Last Name fields, respectively, should result in the Full Name displaying "John Doe."

Here's how you can set this up:

  1. To do so, open up Conditional Fields.
  2. Click “Add condition”.
  3. Choose “First Name” in the 1st dropdown.
  4. Select the “Updates” comparison operator in the 2nd dropdown.
  5. Click “Add Rule Group”.
  6. Choose “Last Name” in the 1st dropdown.
  7. Select the “Updates” comparison operator in the 2nd dropdown.

Next, in the Do section

  1. Select “Full Name” as the target field in the 1st dropdown.
  2. Choose the “Change Value” action in the 2nd dropdown.
  3. Set the value to “{field.first_name} {field.last_name}”

The settings of our condition will look like this:

Here, first_name and last_name are the names of the corresponding fields on our form.

Appending or Prepending Text to Field Value

In the previous example, we saw how to concatenate two field values. Let's customize the Full Name field to say, "My name is John Doe."

Open up Conditional Fields. In the “Do” section, change the value of the 3rd option to “My name is {field.first_name} {field.last_name}”.

The settings of our condition will look like this: