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_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 : array { global $FIXED_LIST_FIELD_TYPES Do not translate node name. Only relevant if $nodeinfo=false
$auto_order_checkbox
$auto_order_checkbox_case_insensitive;
a return

Return

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

Location

include/resource_functions.php lines 8051 to 8100

Definition

 
function get_field_options(int $refbool $nodeinfo falsebool $skip_translation false) : array
    {
    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 17th November 2024 15:05 Europe/London time based on the source file dated 15th November 2024 18:30 Europe/London time.