Working …
This value you provided is not a number. Please try again.
This value you provided is not an integer. Please try again.
The value entered is not a valid Vanderbilt Medical Record Number (i.e. 4- to 9-digit number, excluding leading zeros). Please try again.
The value you provided must be within the suggested range
The value you provided is outside the suggested range
This value is admissible, but you may wish to double check it.
The value entered must be a time value in the following format HH:MM within the range 00:00-23:59 (e.g., 04:32 or 23:19).
This field must be a 5 or 9 digit U.S. ZIP Code (like 94043). Please re-enter it now.
This field must be a 10 digit U.S. phone number (like 415 555 1212). Please re-enter it now.
This field must be a valid email address (like joe@user.com). Please re-enter it now.
The value you provided could not be validated because it does not follow the expected format. Please try again.
Required format:
REDCap Logo
Plugins, Hooks, & External Modules
Developer methods for
Plugins, Hooks, & External Modules
Hook functions

REDCap Developer Tools:
Documentation for Plugins, Hooks, & External Modules

REDCap Version 14.9.1
REDCap::getFieldType
(REDCap >= 5.5.0)
REDCap::getFieldType — Determines the field type for a specified field in the current project
Description
string REDCap::getFieldType ( string $field_name )
Returns the field type for a specified field in the current project. The field type corresponds to the values seen in the Data Dictionary (e.g., dropdown, yesno, notes, slider).

NOTE: Please note that "dropdown" and "notes" fields actually have an element_type of "select" and "textarea", respectively, in the redcap_metadata database tables, although all other fields have an element_type value the same as their field type value. This is important to know if you ever query the redcap_metadata tables directly.
Parameters
field_name
A field's variable name. If field_name is invalid for the project, returns FALSE.
Return Values
Returns the specified field's type as a string.
Restrictions
This method can ONLY be used in a project context (i.e. when "pid" parameter is in the query string of the plugin URL) or else a fatal error is produced.
Examples
Example #1:
This example illustrates how one might obtain a field's type to make a decision in the code logic.
// Set the field variable name manually for this example
$field = 'first_name';

// Check if the field is a checkbox or not
if (REDCap::getFieldType($field) == 'checkbox') {
    // Do something for checkbox fields

} else {
    // Do something for all other field types

}
REDCap 14.9.1 - © 2024 Vanderbilt University