Collections functions
General functions
Render functions
Theme permission functions
Resource functions

render_radio_buttons_question()

Description

render_radio_buttons_question - Used to display a question with radio buttons

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
$listview bool false Show as vertical list? (false for table view)
$ctx array array Rendering context. Should be used to inject different elements (e.g set the div class, add onclick for select)

Return

void

Location

include/render_functions.php lines 5560 to 5630

Definition

 
function render_radio_buttons_question($label$inputname$options = array(), $current=""$extra=""$listview=false, 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}";

    list(
$rows,$cols) = radio_get_layout(array_values($options));
    if(
$listview)
        {
        
$cols=1;
        }
    
?>
    <div class=" echo implode(" "$div_class); ?>">
        <label> echo $label?></label>
        
        <table id=" echo $inputname  "_radio_table"?>" class="radioOptionTable" cellpadding="3" cellspacing="3">                    
            <tbody>
                <tr>
                 
                $row 
1;
                
$col 1;

                foreach(
$options as $optionvalue=>$optiontext)
                    {
                    if(
$col $cols
                        {
                        
$col 1;
                        
$row++; ?>
                        </tr>
                        <tr>
                         
                        
}
                    
$col++;
                    
?>
                    <td width="10" valign="middle">
                        <input type="radio"
                            id="radio_ echo htmlspecialchars($optionvalue); ?>"
                            name=" echo $inputname?>"
                            value=" echo htmlspecialchars($optionvalue); ?>"
                        
                        
if($current == $optionvalue)
                                {
                                
?>
                                checked
                                
                                
}?>>
                    </td>
                    <td align="left" valign="middle">
                        <label class="customFieldLabel"
                            for="radio_ echo htmlspecialchars($optionvalue); ?>"
                            > echo htmlspecialchars($optiontext); ?></label>
                    </td>
                     
                    

                    
?>
                </tr>
            </tbody>
        </table>
        <div class="clearerleft"></div>
    </div>
    
    
return;
    }

This article was last updated 26th September 2022 14:05 Europe/London time based on the source file dated 22nd September 2022 16:20 Europe/London time.