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.


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


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


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


# 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) %>%

# 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