Collections functions
Encryption functions
General functions
Theme permission functions
Resource 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 2987 to 3077

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 htmlspecialchars(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 htmlspecialchars($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 htmlspecialchars(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 htmlspecialchars(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 htmlspecialchars($field_value); ?>">
                    
                    
break;
                }

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

This article was last updated 12th July 2020 06:35 Europe/London time based on the source file dated 8th July 2020 11:40 Europe/London time.