get_field_options()

Description

Get available options for fixed list field types

Parameters

ColumnTypeDefaultDescription
$ref int Metadata field ref
$nodeinfo bool false Get full node details?
$skip_translation bool false Do not translate node name. Only relevant if $nodeinfo=false

Return

array|bool Array of field options, either as a simple array or with full node details

Location

include/resource_functions.php lines 7402 to 7440

Definition

 
function get_field_options(int $refbool $nodeinfo falsebool $skip_translation false)
{
    global 
$FIXED_LIST_FIELD_TYPES$auto_order_checkbox,$auto_order_checkbox_case_insensitive;
    
# For the field with reference $ref, return a sorted array of options. Optionally use the node IDs as array keys
    
if (!is_int_loose($ref)) {
        return 
false;
    }

    
$field get_resource_type_field($ref);
    if (!
in_array($field["type"], $FIXED_LIST_FIELD_TYPES)) {
        return 
false;
    }

    
$options get_nodes($refnull$field["type"] == FIELD_TYPE_CATEGORY_TREE);
    if (
$options === false) {
        return 
false;
    }
    for (
$m 0$m count($options); $m++) {
        if (!
$nodeinfo) {
            if (
$field["type"] == FIELD_TYPE_CATEGORY_TREE) {
                
$options[$m] = $skip_translation $options[$m]["path"] : $options[$m]["translated_path"];
            } else {
                
$options[$m] = $skip_translation $options[$m]["name"] : $options[$m]["translated_name"];
            }
        } else {
            unset(
$options[$m]["resource_type_field"]); // Not needed
        
}
    }

    if (!
$nodeinfo && $field["type"] == FIELD_TYPE_CHECK_BOX_LIST && $auto_order_checkbox) {
        if (
$auto_order_checkbox_case_insensitive) {
            
natcasesort($options);
        } else {
            
sort($options);
        }
    }

    return 
$options;
}

This article was last updated 24th June 2025 17:35 Europe/London time based on the source file dated 5th June 2025 10:55 Europe/London time.