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 3456 to 3546

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"];

            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="custom_ echo $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 $field_id?>"
                              class="stdwidth MultiLine"
                              name=" echo $field_name?>"
                              rows=6
                              cols=50> echo escape($field_value); ?></textarea>
                    
                    
break;

                case 
FIELD_TYPE_DROP_DOWN_LIST:
                    
?>
                    <select id=" echo $field_id?>" class="stdwidth" name=" echo $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 $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:
                    
?>
                    <input type=text
                           id=" echo $field_id?>"
                           class="stdwidth"
                           name=" echo $field_name?>"
                           value=" echo escape($field_value); ?>">
                    
                    
break;
                }

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

This article was last updated 17th November 2024 15:35 Europe/London time based on the source file dated 13th November 2024 14:05 Europe/London time.