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

render_custom_fields()

Description

Render custom fields (NOT metadata fields)

Parameters

ColumnTypeDefaultDescription
$cfs array Custom fields information (as returned by process_custom_fields_submission function)

Return

true

Location

include/render_functions.php lines 3473 to 3582

Definition

 
function render_custom_fields(array $cfs)
    {
    return 
array_walk($cfs, function($field$i)
        {
        
render_question_div("Question_{$field["html_properties"]["id"]}", function() use ($field)
            {
            
$field_id    $field["html_properties"]["id"];
            
$field_name  $field["html_properties"]["name"];
            
$field_value $field["value"];

            
$show_help_text = isset($field['help_text']) && trim($field['help_text'] !== '');
            
$help_js $show_help_text
                
sprintf('onblur="HideHelp(\'%1$s\');" onfocus="ShowHelp(\'%1$s\');"'escape($field_id))
                : 
'';

            global 
$FIXED_LIST_FIELD_TYPES;
            
$selected_options_hashes array_map(function($opt) use ($field_id)
                {
                return 
md5("{$field_id}_{$opt}");
                }, (
in_array($field["type"], $FIXED_LIST_FIELD_TYPES) ? $field["selected_options"] : array()));

            
$required_html = ($field["required"] ? "<sup>*</sup>" "");
            
?>
            <label for=" echo escape($field_id); ?>"> echo escape(i18n_get_translated($field["title"])) . $required_html?></label>
            
            
switch($field["type"])
                {
                case 
FIELD_TYPE_TEXT_BOX_MULTI_LINE:
                    
?>
                    <textarea id=" echo escape($field_id); ?>"
                              class="stdwidth MultiLine"
                              name=" echo escape($field_name); ?>"
                              rows=6
                              cols=50> echo escape($field_value); ?></textarea>
                    
                    
break;

                case 
FIELD_TYPE_DROP_DOWN_LIST:
                    
?>
                    <select id=" echo escape($field_id); ?>" class="stdwidth" name=" echo escape($field_name); ?>">
                    
                    
foreach($field["options"] as $f_option)
                        {
                        
$computed_value md5("{$field_id}_{$f_option}");
                        
$label escape(i18n_get_translated($f_option));
                        
$extra_attributes = (in_array($computed_value$selected_options_hashes) ? " selected" "");

                        echo 
render_dropdown_option($computed_value$label, array(), $extra_attributes);
                        }
                    
?>
                    </select>
                    
                    
break;

                case 
FIELD_TYPE_CHECK_BOX_LIST:
                    
?>
                    <div>
                    
                    
foreach($field["options"] as $f_option)
                        {
                        
$computed_value md5("{$field_id}_{$f_option}");
                        
$label escape(i18n_get_translated($f_option));
                        
$checked = (in_array($computed_value$selected_options_hashes) ? " checked" "");
                        
?>
                        <div class="Inline">
                            <input type="checkbox" name=" echo escape($field_name); ?>" value=" echo $computed_value?>" echo $checked?>>&nbsp; echo $label?>
                        </div>
                        
                        
}
                        
?>
                        <div class="clearerleft"></div>
                    </div>
                    
                    
break;

                case 
FIELD_TYPE_TEXT_BOX_SINGLE_LINE:
                default:
                    
// Allow plugins to render (their own) custom field types
                    
if (hook('render_custom_fields_default_case_override''', [$field]) !== false) {
                        break;
                    }
                    
?>
                    <input type=text
                           id=" echo escape($field_id); ?>"
                           class="stdwidth"
                           name=" echo escape($field_name); ?>"
                           value=" echo escape($field_value); ?>"
                            echo $help_js?>
                    >
                    
                    
break;
                }

            if (
$show_help_text) {
                
?>
                <div id="help_ echo escape($field_id); ?>" class="FormHelp" style="display: none;">
                    <div class="FormHelpInner"> echo escape($field['help_text']); ?></div>
                </div>
                
            
}

            if(isset(
$field["error"]) && trim($field["error"]) != "")
                {
                
?>
                <div class="FormError"> echo escape($field["error"]); ?></div>
                
                
}
            });
        });
    }

This article was last updated 4th December 2024 08:35 Europe/London time based on the source file dated 3rd December 2024 11:55 Europe/London time.