summaryrefslogtreecommitdiff
path: root/libs/plugins/function.custom_radio_bool.php
blob: 511e07a7e02518460ef0380403bc5f55d12ac575 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?php
function smarty_function_custom_radio_bool($params)
{
    extract($params);
    global $select_options, $params, $errors;

    if (! isset($param_in_form)) {
        $param_in_form = $param;
    }

    $checked_val = $params[$param];

    $val_arr = array(1 => 'on', 0 => 'off');

    echo '<div class="radio_bool">';
    foreach ($val_arr as $val => $label) {
        $radio_id = "{$param}_{$val}";

        printf('<input type="radio" name="%s" id="%s" value="%s" %s>'.
               '<label for="%s">%s</label>',
               $param_in_form, $radio_id, $val, ($val == $checked_val) ? 'checked' : NULL,
               $radio_id, $label);
    }

    if ($error) {
        echo '<br>'. $error;
    }

    echo '</div>';
}