Collections functions
General functions
Node functions
Render functions
Theme permission functions
User 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 5661 to 5729

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

    
$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 escape($optionvalue); ?>"
                            name=" echo $inputname?>"
                            value=" echo escape($optionvalue); ?>"
                        
                        
if($current == $optionvalue)
                                {
                                
?>
                                checked
                                
                                
}?>>
                    </td>
                    <td align="left" valign="middle">
                        <label class="customFieldLabel"
                            for="radio_ echo escape($optionvalue); ?>"
                            > echo escape($optiontext); ?></label>
                    </td>
                     
                    

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

This article was last updated 19th March 2024 11:35 Europe/London time based on the source file dated 15th March 2024 17:00 Europe/London time.