Collections functions
General functions
Node functions
Render functions
Theme permission functions
User functions
Resource 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 7873 to 7922

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 21st May 2024 12:05 Europe/London time based on the source file dated 20th May 2024 14:55 Europe/London time.