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

admin_resource_type_field_option()

Parameters

ColumnTypeDefaultDescription
$propertyname string
$propertytitle string
$helptext string
$type
$currentvalue
$fieldtype int
$system_date_field bool
$resource_type_array;
$lang
$baseurl_short
$FIXED_LIST_FIELD_TYPES
$daterange_edtf_support
$allfields
$newfield
$resource_type_array
$existingrestypes
$regexp_slash_replace

Location

include/render_functions.php lines 6623 to 7020

Definition

 
function admin_resource_type_field_option(string $propertyname,string $propertytitlestring $helptext$type,$currentvalue,int $fieldtypebool $system_date_field) : void
    
{
    
debug_function_call("admin_resource_type_field_option",func_get_args());

    global 
$ref,$lang$baseurl_short,$FIXED_LIST_FIELD_TYPES$daterange_edtf_support$allfields$newfield,
    
$resource_type_array$existingrestypes$regexp_slash_replace$resource_type_array;
    if(
$propertyname=="linked_data_field")
        {
        if(
$fieldtype==FIELD_TYPE_DATE_RANGE && $daterange_edtf_support)
            {
            
// The linked_data_field column is is only used for date range fields at present
            
$propertytitle $lang["property-field_raw_edtf"];
            }
        else
            {
            return;
            }
        }
    
$resource_types=get_resource_types("",true,false,true);
    foreach(
$resource_types as $resource_type)
        {
        
$resource_type_array[$resource_type["ref"]]=$resource_type["name"];
        }
    
    if(
$propertyname == 'regexp_filter')
        {
        
$currentvalue str_replace($regexp_slash_replace'\\', (string) $currentvalue);
        }
        
    
$alt_helptext=hook('rtfieldedithelptext''admin_resource_type_field_edit', array($propertyname));
    if(
$alt_helptext!==false){
        
$helptext=$alt_helptext;
    }
    
    
?>
    <div class="Question" >
        <label> echo ($propertytitle!="") ? escape((string) $propertytitle) : escape((string) $propertyname); ?></label>
        
        
if($propertyname=="global")
            { 
            
// Special case - new global/resource type selector
            
?>
            <table>
                <tr>
                    <td>
                        <input type="checkbox" 
                            name="global" 
                            id="globalfield" 
                            value="1"
                             if($currentvalue == 1) { ?> checked="checked" ?>s
                            onchange="showHideResTypeSelector();">
                         echo escape($lang["resourcetype-global_field"]) ?>
                    </td>
                </tr>
                
                
foreach($resource_type_array as $resource_type=>$restypename)
                    {
                    
?>
                    <tr>
                        <td>
                            <input type="checkbox"
                                name="field_restype_select_ echo escape($resource_type); ?>"
                                id="field_restype_select_ echo escape($resource_type); ?>
                                class="field_restype_select"
                                value="1"
                                 if($currentvalue == 1) { ?> disabled="true" ?>
                                 if(in_array($resource_type,$existingrestypes)) { ?> checked="checked" ?>>
                             echo escape($restypename?>
                        </td>
                    </tr>
                    
                    
}
                
?>
            </table>
            <script>
            function showHideResTypeSelector() {
                if(jQuery("#globalfield").prop("checked")){
                    jQuery(".field_restype_select").display = 'none';
                    jQuery(".field_restype_select").prop('checked',false);
                    jQuery(".field_restype_select").prop('disabled',true);
                }
                else {                    
                    jQuery(".field_restype_select").display = 'block';
                    jQuery(".field_restype_select").prop('disabled',false);
                }
            }
            </script>

            
}
        elseif(
$propertyname=="type")
            {
            global 
$field_types;

            
// Sort  so that the display order makes some sense
            //natsort($field_types);
            
?>
                <select id="field_edit_ echo escape((string) $propertyname); ?>"
                        name=" echo escape((string) $propertyname); ?>"
                        class="stdwidth"
                        onchange="
                                 if(!$newfield)
                                {
?>
                                newval=parseInt(this.value);
                                if((jQuery.inArray(newval,fixed_list_fields) > -1) && (jQuery.inArray(current_type,text_fields) > -1))
                                    {
                                    jQuery('input[name=\'keywords_index\']')[0].checked = true;

                                    if(confirm(' echo escape($lang["admin_resource_type_field_migrate_data_prompt"]) ?>'))
                                        {
                                        jQuery('#migrate_data').val('yes');
                                        }
                                    else
                                        {
                                        jQuery('#migrate_data').val('');
                                        }

                                    this.form.submit();
                                    }

                                    else if ((jQuery.inArray(newval,text_fields) > -1) && (jQuery.inArray(current_type,fixed_list_fields) > -1)) 
                                {
                                    if(confirm(' echo escape($lang["admin_resource_type_field_cannot_migrate_data_prompt"]) ?>'))
                                        {
                                            this.form.submit(); 
                                        } else {
                                            jQuery('#field_edit_type').val(current_type);
                                        }
                                }
                                else
                                    {
                                    this.form.submit();
                                    }
                                
                                
}
                            else
                                {
                                
?>
                                this.form.submit();
                                
                                
}
                                
?>
                ">
                
                
foreach($field_types as $field_type=>$field_type_description)
                    {
                    
?>
                    <option value=" echo $field_type ?>" if ($currentvalue == $field_type) { echo " selected"; } ?>> echo escape($lang[$field_type_description])  ; ?></option>
                    
                    
}
                
?>
                </select>
            
            
if (in_array($currentvalue$FIXED_LIST_FIELD_TYPES))
                {
                
?>
                <div class="clearerleft"></div>
                </div> <!-- end question -->

                <div class="Question">
                    <label>  echo escape($lang['options']) ; ?></label>
                    <span><a href=" echo $baseurl_short ?>pages/admin/admin_manage_field_options.php?field= echo $ref ?>" onClick="return CentralSpaceLoad(this,true);">  echo escape($lang['property-options_edit_link']) ; ?></a></span>
                    <div class="clearerleft"></div>

                
                
if(FIELD_TYPE_CATEGORY_TREE != $currentvalue)
                    {
                    
?>
                    </div>
                    
                    $field_index              
array_search($refarray_column($allfields'ref'));
                    
$automatic_nodes_ordering = (false !== $field_index $allfields[$field_index]['automatic_nodes_ordering'] : 0);
                    
?>
                    <div class="Question">
                        <label>  echo escape($lang['property-automatic_nodes_ordering_label']) ; ?></label>
                        <input type="checkbox" name="automatic_nodes_ordering" value="1" if(== $automatic_nodes_ordering) { ?> checked="checked" ?>>
                    
                    
// create constraints selector
                    
admin_resource_type_field_constraint($ref, (int)$currentvalue);
                    }
                }
            elseif (
in_array($currentvalue, array(FIELD_TYPE_TEXT_BOX_SINGLE_LINE)))
                { 
                
// create constraints selector
                
admin_resource_type_field_constraint($ref, (int)$currentvalue);
                }
            }
        elseif(
$propertyname=="linked_data_field")
            {
            if (
$fieldtype==FIELD_TYPE_DATE_RANGE && $daterange_edtf_support)
                {
                
// The linked_data_field column is is only used for date range fields at present            
                // Used to store the raw EDTF string submitted
                
?>
                <input id="linked_data_field" name="linked_data_field" type="text" class="stdwidth" value=" echo escape((string) $currentvalue)?>">

                
}
            }
        elseif(
$propertyname === 'tab')
            {
            
?>
            <select class="stdwidth" name=" echo escape($propertyname); ?>">
            
            
foreach(get_tab_name_options() as $tab_ref => $tab_name)
                {
                
$selected $tab_ref === (int) $currentvalue 'selected' '';
                
?>
                <option value=" echo (int) $tab_ref?> echo $selected?>> echo escape((string) $tab_name); ?></option>
                
                
}
            
?>
            </select>
            
            
}
        elseif(
$propertyname == 'partial_index')
            {
            
?>
            <input 
                id="field_edit_ echo escape((string) $propertyname); ?>"
                name=" echo escape((string) $propertyname); ?>"
                type="checkbox"
                value="1"
                 if ($currentvalue==1) { ?> checked="checked" ?>
                onchange='handleIndexOptions(this, "field_edit_complete_index")'
                >
            
            
}
        elseif (
$propertyname == 'complete_index')
            {
            
?>
            <input 
                id="field_edit_ echo escape((string) $propertyname); ?>"
                name=" echo escape((string) $propertyname); ?>"
                type="checkbox"
                value="1"
                 if ($currentvalue==1) { ?> checked="checked" ?>
                onchange="handleIndexOptions(this, 'field_edit_partial_index')"
                >
            
        
} elseif ($propertyname == 'sort_method') {
            
?>
            <select class="stdwidth" name=" echo escape($propertyname); ?>">
             
            
foreach(FIELD_SORT_METHODS as $method => $value) {
                
$selected $value === $currentvalue 'selected' '';
                
?>
                <option
                    value=" echo (int) $value?> echo $selected?>
                    > echo escape($lang["sort-method_$method"]); ?>
                </option>
             }
            
?>
            </select>
            
        
} elseif ($propertyname == 'geomapping') {
            
$geo_location_fields ps_array("SELECT geomapping value FROM resource_type_field WHERE geomapping !=0 ORDER BY geomapping", []);
            
$disabled_options = [];
            if (!empty(
$geo_location_fields) && [$currentvalue] != $geo_location_fields) {
                
// At least one other field is using geo mapping
                
if (in_array(FIELD_GEO_LOCATION::both->value$geo_location_fields)) {
                    
// A field is set to both, no options here except none
                    
$disabled_options = [
                        
FIELD_GEO_LOCATION::both,
                        
FIELD_GEO_LOCATION::latitude,
                        
FIELD_GEO_LOCATION::longitude
                    
];
                } else {
                    
// At least one field is lat or long, only allow one of these if not set elsewhere
                    
$disabled_options[] = FIELD_GEO_LOCATION::both;
                    if (
in_array(FIELD_GEO_LOCATION::latitude->value$geo_location_fields)
                        && 
$currentvalue != FIELD_GEO_LOCATION::latitude->value) {
                        
$disabled_options[] = FIELD_GEO_LOCATION::latitude;
                    }
                    if (
in_array(FIELD_GEO_LOCATION::longitude->value$geo_location_fields)
                        && 
$currentvalue !=FIELD_GEO_LOCATION::longitude->value) {
                        
$disabled_options[] = FIELD_GEO_LOCATION::longitude;
                    }
                }
            }
            
?>
            <select 
                class="stdwidth"
                id="field_edit_geomapping"
                name="geomapping"
                 if (count($disabled_options) == 3) {?>
                    disabled
                    title=" echo escape($lang["disabled-geomapping-title"]);?>"
                 ?>
                >
             
            
foreach(FIELD_GEO_LOCATION::cases() as $case) {
                
$selected $case->value === $currentvalue 'selected' '';
                
$disabled in_array($case$disabled_options) ? 'disabled' '';
                
$value "\"$case->value\" $selected $disabled";
                
?>
                <option
                    value= echo $value?>
                    > echo escape($case->i18n($lang)); ?>
                </option>
             }
            
?>
            </select>
            <script>
                jQuery(document).ready(function()  {
                    var selectedValue = jQuery('#field_edit_type').val();
                    var geoSelect = jQuery('#field_edit_ echo escape((string) $propertyname); ?>');

                    if (selectedValue !== ' echo FIELD_TYPE_TEXT_BOX_SINGLE_LINE?>') {
                        geoSelect.prop('disabled', true).val(0);
                    }
                });
            </script>
            
        
}
        elseif(
$type==1)
            {
            if (
$propertyname=="advanced_search" && $system_date_field)
                {
                
?><input id="field_edit_ echo escape((string) $propertyname); ?>" name=" echo escape((string) $propertyname); ?>" type="checkbox" value="1" checked="checked" onclick="return false;">
                $helptext
=$lang["property-system_date_help_text"];
                }
            else
                {
                
?><input id="field_edit_ echo escape((string) $propertyname); ?>" name=" echo escape((string) $propertyname); ?>" type="checkbox" value="1"  if ($currentvalue==1) { ?> checked="checked" ?>>
                
}
            }
        elseif(
$type==2)
            {
            
?>
            <textarea class="stdwidth" rows="5" id="field_edit_ echo escape((string) $propertyname); ?>" name=" echo escape((string) $propertyname); ?>"> echo escape((string) $currentvalue)?></textarea>
            
            
}
        else
            {
            
?>
            <input id="field_edit_ echo escape((string) $propertyname); ?>" name=" echo escape((string) $propertyname); ?>" type="text" class="stdwidth" value=" echo escape((string) $currentvalue)?>">
            
            
}

        if(
$helptext!="")
                {
                
?>
                <div class="FormHelp" style="padding:0;clear:left;" >
                    <div class="FormHelpInner"> echo strip_tags_and_attributes(str_replace("%ref",$ref,$helptext), ["a"], ["href""target"]) ?>
                    </div>
                </div>
                
                
}

    if(
$propertyname == "name")
        {
        
?>
        <div id="shortname_err_msg" class="FormHelp DisplayNone" style="padding:0;clear:left;" >
            <div class="FormHelpInner PageInformal"> echo escape($lang["warning_duplicate_shortname_fields"]) ; ?></div>
        </div>
        <script>
        var validate_shortname_in_progress = false;
        jQuery("input[name='name']").keyup(function(event)
            {
            if(validate_shortname_in_progress)
                {
                return;
                }

            validate_shortname_in_progress = true;

            jQuery.get(
                baseurl + "/pages/admin/ajax/validate_rtf_shortname.php",
                {
                ref: " echo escape($ref); ?>",
                new_shortname: event.target.value
                },
                function (response)
                    {
                    var err_msg_el = jQuery("#shortname_err_msg");
                    if(err_msg_el.hasClass("DisplayNone") === false)
                        {
                        err_msg_el.addClass("DisplayNone");
                        }

                    if(typeof response.data !== "undefined" && !response.data.valid)
                        {
                        err_msg_el.removeClass("DisplayNone");
                        }

                    validate_shortname_in_progress = false;
                    },
                "json");

            return;
            });
        </script>
        
        
}
        
?>
        <div class="clearerleft"></div>
    </div>
    
    
}

This article was last updated 2nd June 2026 17:35 Europe/London time based on the source file dated 2nd June 2026 15:35 Europe/London time.