Coding standards
Security in ResourceSpace
Developer reference
Database
Action functions
Admin functions
Ajax functions
Annotation functions
API functions
Collections functions
Comment functions
Config functions
CSV export functions
Dash functions
Debug functions
Encryption functions
Facial recognition functions
File functions
General functions
Language functions
Log functions
Login functions
Message functions
Migration functions
Node functions
PDF functions
Plugin functions
Render functions
Reporting functions
Request functions
Research functions
Slideshow functions
Theme permission functions
User functions
Video functions
Database functions
Metadata functions
Resource functions
Search functions
Map functions
Job functions
Tab functions
Test functions

get_valid_custom_fields()

Description

Get collection of valid custom fields. A valid fields has at least the expected field properties

IMPORTANT: these fields are not metadata fields - they are configured through config options such as custom_researchrequest_fields

Parameters

ColumnTypeDefaultDescription
$fields array List of custom fields. Often this will simply be the global configuration option (e.g custom_researchrequest_fields)

Return

array

Location

include/request_functions.php lines 1085 to 1113

Definition

 
function get_valid_custom_fields(array $fields)
    {
    return 
array_filter($fields, function($field)
        {
        global 
$lang$FIXED_LIST_FIELD_TYPES;

        
$expected_field_properties = array("id""title""type""required");
        
$available_properties      array_keys($field);
        
$missing_required_fields   array_diff(
            
$expected_field_properties,
            
array_intersect($expected_field_properties$available_properties));

        if(
count($missing_required_fields) > 0)
            {
            
debug("get_valid_custom_fields: custom field misconfigured. Missing properties: "
                
implode(", "array_values($missing_required_fields)));
            return 
false;
            }

        
// options property required for fixed list fields type
        
if(in_array($field["type"], $FIXED_LIST_FIELD_TYPES) && !array_key_exists("options"$field))
            {
            
debug("get_valid_custom_fields: custom fixed list field misconfigured. Missing the 'options' property!");
            return 
false;
            }

        return 
true;
        });
    }

This article was last updated 4th December 2024 08:35 Europe/London time based on the source file dated 18th November 2024 16:40 Europe/London time.