Yoast_Form::checkbox PHP Method

checkbox() public method

Create a Checkbox input field.
public checkbox ( string $var, string $label, boolean $label_left = false )
$var string The variable within the option to create the checkbox for.
$label string The label to show for the variable.
$label_left boolean Whether the label should be left (true) or right (false).
    public function checkbox($var, $label, $label_left = false)
    {
        if (!isset($this->options[$var])) {
            $this->options[$var] = false;
        }
        if ($this->options[$var] === true) {
            $this->options[$var] = 'on';
        }
        $class = '';
        if ($label_left !== false) {
            if (!empty($label_left)) {
                $label_left .= ':';
            }
            $this->label($label_left, array('for' => $var));
        } else {
            $class = 'double';
        }
        echo '<input class="checkbox ', esc_attr($class), '" type="checkbox" id="', esc_attr($var), '" name="', esc_attr($this->option_name), '[', esc_attr($var), ']" value="on"', checked($this->options[$var], 'on', false), '/>';
        if (!empty($label)) {
            $this->label($label, array('for' => $var));
        }
        echo '<br class="clear" />';
    }