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_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 5792 to 5860

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 4th December 2024 08:35 Europe/London time based on the source file dated 3rd December 2024 11:55 Europe/London time.