addFormField

Description

Adds a new form field to a form schema object or retrieves the form schema and adds the new form field. Note that the either the upload argument must be TRUE for the field to be added automatically online or the user will also need to use updateFormSchema() to upload the changes after they are completed.

Usage

addFormField(...)
addFormField(formId, schema, upload = FALSE, ...)
addFormField(formSchema, schema, upload = FALSE, ...)

Arguments

Argument Description
... ignored
formId The identifier of the form online
schema The form field schema to be added to the form
upload Default is FALSE. If TRUE the modified form schema will be uploaded.
formSchema The form schema object

Value

The form field schema after the addition. This will be the form field schema from the server if changes are uploaded.

See also

formSchema , formFieldSchema , addForm

Examples

# Define a few field schema objects
nameField <- textFieldSchema(label = "Your name", required = TRUE)
dobField <- dateFieldSchema(label = "When were you born?", code = "dob")


# Create a new form schema object and add the fields. We are not sending
# anything to the server yet.
survey <- formSchema(databaseId = "cxy123", label = "Household Survey") %>%
   addFormField(nameField) %>%
   addFormField(dobField)

# Retrieve a form schema from the server by id and add a field to it.
# Nothing is changed on the server yet.
updatedSurvey <- addFormField(formId = "cxyz123", nameField)
   
# Retrieve a form schema from the server by id and add a field to it
# AND then send the updated schema to the server. 
addFormField(formId = "cxyz123", nameField, upload = TRUE)
Next item
addRecord