deleteFormField

Description

Deletes a form field from an existing form schema object.

Usage

deleteFormField(...)
deleteFormField(formId, id, code, label, upload = FALSE, ...)
deleteFormField(formSchema, id, code, label, upload = FALSE, ...)

Arguments

Argument Description
... ignored
formId The id of the form online (provide either a formId or formSchema)
id The id of the form field (provide either an id, code, or label)
code The code of the form field (provide either an id, code, or label)
label The label of the form schema (provide either an id, code, or label)
upload Default is FALSE. If TRUE the modified form schema will be uploaded.
formSchema The form schema object (provide either a formId or formSchema)

Details

This function can also be used to immediately delete a field from a form schema on the ActivityInfo server by setting upload to TRUE. Otherwise, use updateFormSchema() to upload the changes after they are completed.

Value

The form field schema after the deletion. 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)
   
# Remove the name field
survey <- deleteFormField(survey, label = "Your name")

# Remove the date of birth field, but use the code to identify the field
survey <- deleteFormField(survey, code = "dob")    

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