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 1025 to 1036

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 14th March 2025 20:35 Europe/London time based on the source file dated 21st January 2025 15:20 Europe/London time.