View source: R/form_schema_ext.R
form_schema_ext | R Documentation |
form_schema_ext(
flatten = FALSE,
odata = FALSE,
parse = TRUE,
pid = get_default_pid(),
fid = get_default_fid(),
url = get_default_url(),
un = get_default_un(),
pw = get_default_pw(),
odkc_version = get_default_odkc_version(),
retries = get_retries(),
verbose = get_ru_verbose()
)
flatten |
Whether to flatten the resulting list of lists ( |
odata |
Whether to sanitise the field names to match the way they will
be outputted for OData. While the original field names as given in the
XForms definition may be used as-is for CSV output, OData has some
restrictions related to the domain-qualified identifier syntax it uses.
Only applies to ODK Central version < 0.8.
Default: |
parse |
Whether to parse the form schema into a tibble of form field
type and name. This uses |
pid |
The numeric ID of the project, e.g.: 2. Default: Set default See |
fid |
The alphanumeric form ID, e.g. "build_Spotlighting-0-8_1559885147". Default: Set default See |
url |
The ODK Central base URL without trailing slash. Default: Set default See |
un |
The ODK Central username (an email address).
Default: |
pw |
The ODK Central password.
Default: |
odkc_version |
The ODK Central version as a semantic version string
(year.minor.patch), e.g. "2023.5.1". The version is shown on ODK Central's
version page Default: Set default See |
retries |
The number of attempts to retrieve a web resource. This parameter is given to Default: 3. |
verbose |
Whether to display debug messages or not. Read |
ODK Central has introduced a new API endpoint in version 0.8 which
returns a parsed and flattened list of fields. This replaces the nested
form schema which is challenging to parse. This list is returned
by form_schema
.
However this still misses important elements, in particular labels
and
choice_lists
.
form_schema_ext
returns the same object as
form_schema
adding labels
and choice lists
in all languages available.
This is done by using the return object from form_xml
.
It has the exact function signature as form_schema
.
In that sense, any call to form_schema
can be replaced
by form_schema_ext
This function, however, has been prepared with ODK Central version 0.8 or higher. If you use it with an earlier version, a warning will be given.
A tibble containing the form definition.
For ODK Central 0.8, and with default parameters
(parse=TRUE
) for ODK Central 0.7, form_schema
returns
a tibble with the columns:
name
The field name as given in the form schema.
type
The field type, e.g. "string", "select1", etc.
path
The XForms path of the field,
ruodk_name
The predicted field name as generated by
odata_submission_get
, prefixed by the path, additionally
cleaned with make_clean_names
to match the
cleaned column names from odata_submission_rectangle
.
label
The field label as given in the form schema.
If specific languages are available,
this column will return the default
language or it will be empty
if this is not specified.
label_lang
The field label in languange _lang as
given in the form schema.
choices
A list of lists containing at least values
and,
if available, labels
of the choices as given in the form schema.
If specific languages are available, this column will return the
default
language or it will be empty if this is not specified.
Please notice that whenever choice filters are applied, this will return
the unfiltered choice list.
choices_lang
A list of lists containing at least
values
and, if available, labels
of the choices in language
_lang as given in the form schema.
Please notice that whenever choice filters are applied, this will return
the unfiltered choice list.
https://docs.getodk.org/central-api-form-management/#getting-form-schema-fields
https://docs.getodk.org/central-api-form-management/#retrieving-form-xml
Other form-management:
form_detail()
,
form_list()
,
form_schema()
,
form_xml()
## Not run:
# See vignette("setup") for setup and authentication options
# ruODK::ru_setup(svc = "....svc", un = "me@email.com", pw = "...")
# With current ODK Central (>0.7)
# get extended schema:
fsx <- form_schema_ext()
# print choice list in english:
fsx[fsx$name == "test_yn", "choices_english_(en)"][[1]]
# view the extended schema:
fsx
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.