REDCap Field Embedding

Summary

Field Embedding allows users to customize how fields are displayed and structured on forms and surveys. In essence, field embedding works by allowing users to embed one field into another. For example, multiple fields can be placed within a field that has a table, so that the content is displayed in a compact and categorized manner, improving the user experience.

Best Practice

  • Separate field embedded content into sections by using the 'Begin New Section' field type throughout an instrument.

  • Provide a field label for a field even if it is being embedded. This makes it easier to identify fields when developing an instrument and viewing reports.

  • Use the rich text editor when creating customized field embeds. The rich text editor offers formatting options such as tables, etc.

  • Note: Field embedding should not be confused with REDCap’s piping feature, which is used to pipe previously collected data into a field. Ex:

{variable_name}  → Field Embedding
[variable_name]  → Piping

Capabilities

  • Fields can be embedded within:

    • Other Field Labels

    • 'Begin New Section' Fields

    • Within the answer choices of most fields

  • Supports Branching Logic

Limitations

  • Fields cannot be embedded within:

    • Themselves via Field Label

    • Answer choices for the Drop-down list field type

    • Survey Instructions

    • Survey Acknowledgement Text

    • Survey Queue Text

    • Outgoing Emails/Invites/Alerts

  • Field embedding only pulls in the answer choices, not the field label (the question), with the exception of Descriptive Text fields.

  • Record ID is an identifier field and cannot be embedded.

  • Field Embedding does not work across different instruments/surveys.

  • Embedded elements in a Descriptive Field must be located on the same page when using the multi-page feature found in the Survey Settings.

  • Currently, Field Embedding does not work in the REDcap Mobile App ‘MyCap.’

Create an Embedded Field

Level: Beginner

Fields are embedded by encasing the variable name of a field in curly braces {variable_name} and placing it within the field label or answer choice of a different field. Field embedding inserts the answer choices from one field into another; it does not embed the field label (the question) itself. However Descriptive Text fields are the only notable exception. The following example will showcase how to embed two Text Box fields into a Descriptive Text field, allowing the two text box fields to display side by side, as shown in the image below: 
 

Picture of Field Embedding Animated GIF

  1. Create two Text Box fields. In this example, the text box fields named first_name and last_name will be embedded into a descriptive text field later in the steps. 
    Picture of Instrument Variables

  2. Create a Descriptive Text field and enable Use the Rich Text Editor. This field will contain variables we wish to embed, in this case, first_name and last_name from the previous step.
    Picture of Descriptive Text Field

  3. When embedding fields, the use of tables is not required. However, they can be a useful organizational tool when embedding multiple fields. To create a table, select the table icon. Select enough cells to organize the embedded fields. This example will use two Columns and one Row.
    Picture of Creating a Table

  4. Within each cell, manually type the field labels from the two Text Box fields created in Step 1. In this example, the field labels that were manually typed are 'First Name:' and 'Last Name:'. Then, encase the variable name of each text box within curly brackets, ex. {first_name}, and place it next to its’ relative field label. Click Save.


     

  5. Visually confirm that the field embed has taken effect by locating the blue and green flags on both the Text Box and Descriptive Text fields. Embedded fields will have a green flag. Fields containing embedded fields will have a blue flag.
    Picture of Field Embedding Flags

  6. Periodically view the survey to track changes by navigating to Survey Distribution Tools and clicking the Open Public Survey button to open the survey. In this example, notice that the table has borders.
    Picture of Completed Field Embedding With Borders

    1. (Optional) To remove the table border, return to the instrument and edit the descriptive text field. Click on the table itself and then select the table icon. Select 'Table properties' from the drop-down menu.
      Picture of Table Properties Icon

    2. Enter '0' in the border width box to remove the table borders. Click Save to commit the table changes. Click Save again to commit the changes to the entire field.

      Picture of Table Properties WindowPicture of Save Button
       

    3. Open the public survey link to view the changes.
      Picture of Completed Field Embedding

Embed a Field into an Answer Choice (with Branching Logic)

Level: Intermediate


In addition to embedding one field into another, it can also be especially useful to pair branching logic with an embedded field. In the following example, a textbox will be embedded next to the answer choice 'Other', allowing participants to provide a unique response when 'Other' is selected. Branching logic will be used so that the textbox only appears next to 'Other' when it is selected, as shown in the GIF below.
 

Picture of Completed Embedded Field

  1. Create a Multiple Choice - Radio Button field with various answer choices. In the example below, the favorite_color field asks users for their favorite color with five (5) potential answer choices. Note that answer choice five is listed as Other.
    Picture of Multiple Choice Radio Button Field

  2. Create a Text Box field. When embedded, this variable will allow participants the ability to provide a unique written response when they select Other.
    Picture of Field Variables

  3. Edit the radio button favorite_color field and embed the text box variable in curly brackets {other_color} , to the right of the answer choice 5, Other as shown in the image below. Click Save to commit the changes.
    Picture of Answer Choices

  4. Visually confirm that field embedding has taken effect by locating the blue and green flags on both radio button favorite_color and text box other_color fields. Embedded fields will have a green flag. Fields containing embedded fields will have a blue flag.
    Picture of Field Embedding Flags

  5. Open the public survey link to view the changes. The text box {other_color} field now appears next to 'Other' answer choice and remains visible despite being unselected. 
    Picture of Answer Choice Other

  6. Return to the instrument and open the branching logic menu for the other_color field by clicking the green branching logic icon.
    Picture of Branching Logic Icon

  7. Insert the logic [favorite_color] = ‘5’ in the Logic Editor. This is so that the text box {other_color} field only appears when answer choice 'Other' from question {favorite_color} field has been selected. To commit the changes, click 'Update & Close Editor' and then click Save. Click here to learn how to use branching logic (WIP).
    Picture of Branching Logic Window

  8. Notice that the branching logic statement is displayed on the field, which can be a helpful visual indicator to identify the branching logic condition.
    Picture of Branching Logic Statement On A Variable

  9. Open the public survey link to view the changes. Notice in the example below that text box {other_color} field remains hidden until answer choice “5, Other” has been selected.
    Picture of Completed Text Box Field Embed

Embed Multiple Fields into a Table (with Branching Logic)

Level: Expert


To maximize the user experience, it sometimes makes sense to group related questions together in a compact manner. The following example will demonstrate advance field embedding and showcase how branching logic is used to hide embedded questions (field labels) and answer choices until conditions are met. The branching logic questions will appear to the right of the parent question, as shown in the image below:
 

Picture of Completed Embedded Multiple Fields

 

  1. Create a Radio Button field with a question and three answer choices. This field will serve as the parent decision question. When certain choices are selected, additional questions will pop-up to the right of the parent question. In this example, selecting the answer choice Yes will cause the additional questions to appear once branching logic is added, which will be explained later in the steps.
    Picture of Radio Button Field

  2. Create two fields, a Radio Button field with four answer choices and a Text Box field. Enter a field label (question) for each field. Although the field label doesn’t get "pulled" when it’s embedded, adding field labels helps users to quickly identify fields when developing an instrument and when viewing reports. For this example, radio button favorite_exercise and text box running fields were created.
    Picture of Two Fields, a Radio Button and Text Box Fields

  3. Create two new Descriptive Text fields located below the “running” field and enter a field label question. The field label from a descriptive text field can be embedded (i.e. it can be “pulled in” unlike other fields types, which can only have their answer choices embedded), and be viewable to users within a survey. Note that the variable names include an “_q”, as a reference that the question is associated with the favorite_exercise field.

    Picture of Two Descriptive Fields
     

  4. Create a Descriptive Text field and enable Use the Rich Text Editor. The five fields created in steps 2 and 3 will be embedded into this field, exercise_embded.
    Picture of Descriptive Field

  5. In the field label, create a table with enough cells to organize the embedded fields. This example will use three Columns and two Rows.
    Picture of Creating a Table

  6. The table layout below emphasizes the parent question {exercise} located in Column one. Column two will be used as a margin. The variables created in Steps 2 and 3 will be embedded in column three and controlled with branching logic.
    Picture of Table Layout

  7. Select the two Rows in Column one and right click. A popup menu will appear, click Cell and then Merge cells.
    Picture of Merging Table Cells

  8. Type in the field label text and embed {exercise} into the cell. Adjust the vertical lines in Column two to create a suitable blank center margin.

    Picture of Field Label and Embedded Variable
     

  9. Embed {favorite_exercise_q} and {favorite exercise} fields into Column three Row one. Embed {running_q} and {running} fields into Column three Row two. Then click Save.
    Picture of Embedded Variables

  10. Insert [exercise]=’1’ as branching logic into the {favorite_exercise_q} and {favorite exercise} fields. This is so that {favorite_exercise_q} and {favorite_exercise} fields only appear when the answer choice 'Yes' is selected in the {exercise} question field.

    Picture of Branching Logic Statements For Second Question
     

  11. Insert [favorite_exercise]=’2’ branching logic into the {running_q} and {running} fields. As a result, {running_q} and {running} fields will only appear when answer choice 'Running' is selected in the {favorite_exercise} question field.
    Picture of Branching Logic Statements For Third Question

  12. Open the public survey link to view the changes. The embedded questions and answer choices are now hidden until the branching logic conditions are met.
    Picture of Completed Embedded Questions

Print Article

Details

Article ID: 996
Created
Tue 12/20/22 3:35 PM
Modified
Wed 8/30/23 11:47 AM

Related Articles (8)

This article describes the steps to enable surveys in REDCap
How to break out of a survey
Primary methods on how to add multiple participants with unique identifiers
Instructions on how to set up Automated Survey Invitations (ASI) in REDCap
Instructions on how to enable the Form Display Logic in a REDCap Project
Instructions on how to set up Survey Login in a REDCap project
Instructions on how to enable the Survey Queue in a REDCap Project
This document explores each setting on the Survey Settings page including survey status, basic survey formatting, survey completion options, enable e-consent, and more.