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_dropdown_question()

Description

render_dropdown_question - Used to display a question with a dropdown selector

Parameters

ColumnTypeDefaultDescription
$label string Label of question
$inputname string Name of input field
$options array array Array of options (value and text pairs) (eg. array('pixelwidthmin'=>'From','pixelwidthmin'=>'To')
$current string "" The current selected value
$extra string "" Extra attributes used on the selector element
$ctx array array Rendering context. Should be used to inject different elements (e.g set the div class, add onchange for select)

Return

void

Location

include/render_functions.php lines 1657 to 1686

Definition

 
function render_dropdown_question($label$inputname$options = array(), $current=""$extra="", array $ctx = array())
    {
    
$div_class = array("Question");
    if(isset(
$ctx["div_class"]) && is_array($ctx["div_class"]) && !empty($ctx["div_class"]))
        {
        
$div_class array_merge($div_class$ctx["div_class"]);
        }
    
$input_class = isset($ctx["input_class"]) ? $ctx["input_class"] : "stdwidth";

    
$onchange = (isset($ctx["onchange"]) && trim($ctx["onchange"]) != "" trim($ctx["onchange"]) : "");
    
$onchange = ($onchange != "" sprintf("onchange=\"%s\""$onchange) : "");

    
$extra .= {$onchange}";
    
?>
    <div class=" echo escape(implode(" "$div_class)); ?>">
        <label> echo escape($label); ?></label>
        <select  name=" echo escape($inputname); ?>" class=" echo escape($input_class); ?>" id=" echo escape($inputname); ?> echo $extra?>>
        
        
foreach ($options as $optionvalue=>$optiontext)
            {
            
?>
            <option value=" echo escape(trim((string)$optionvalue))?> if (trim((string)$optionvalue)==trim((string)$current)) {?>selected ?>> echo escape(trim((string)$optiontext))?></option>
            
            
}
        
?>
        </select>
        <div class="clearerleft"></div>
    </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.