deleteFormField: Delete a form field

View source: R/formField.R

deleteFormFieldR Documentation

Delete a form field

Description

Deletes a form field from an existing form schema object.

Usage

deleteFormField(...)

## S3 method for class 'character'
deleteFormField(formId, id, code, label, upload = FALSE, ...)

## S3 method for class 'formSchema'
deleteFormField(formSchema, id, code, label, upload = FALSE, ...)

Arguments

...

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")    

## Not run: 
# 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)    

## End(Not run)

bedatadriven/activityinfo-R documentation built on Dec. 21, 2024, 8:23 a.m.