Collections functions
General functions
Node functions
Render functions
Theme permission functions
User functions
Resource 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 1650 to 1679

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 19th March 2024 06:05 Europe/London time based on the source file dated 15th March 2024 17:00 Europe/London time.