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

gen_custom_fields_html_props()

Description

Generate HTML properties for custom fields. These properties can then be used by other functions
like render_custom_fields or process_custom_fields_submission

assumes fields have been validated

Parameters

ColumnTypeDefaultDescription
$fields array List of custom fields as returned by get_valid_custom_fields(). Note: At this point code
$ctx: array $ctx['html_properties_prefix'] ?? 'custom_field_'; return array_mapfunction$field use $prefix
$ctx array Contextual information for {@see process_custom_fields_submission()}

Return

array Returns collection items with the extra "html_properties" key

Location

include/request_functions.php lines 1126 to 1138

Definition

 
function gen_custom_fields_html_props(array $fields, array $ctx): array
    {
    
$prefix $ctx['html_properties_prefix'] ?? 'custom_field_';
    return 
array_map(function($field) use ($prefix)
        {
        
$ident $prefix $field['id'];
        
$field["html_properties"] = array(
            
"id"   => $ident,
            
"name" => (!empty($field["options"]) ? "{$ident}[]" $ident),
        );
        return 
$field;
        }, 
$fields);
    }

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