Habari\Utils::html_checkboxes PHP Method

html_checkboxes() public static method

Creates one or more HTML checkboxes
public static html_checkboxes ( string $name, array $options ) : string
$name string The name of the checkbox element. If there are multiple checkboxes for the same name, this method will automatically apply "[]" at the end of the name
$options array An array of checkbox options. Each element should be an array containing "name" and "value". If the checkbox should be checked, it should have a "checked" element.
return string The HTML of the checkboxes
    public static function html_checkboxes($name, $options)
    {
        $output = '';
        $multi = false;
        if (count($options > 1)) {
            $multi = true;
        }
        foreach ($options as $option) {
            $output .= '<input type="checkbox" id="' . $option['name'] . '" name="' . $option['name'];
            if ($multi) {
                $output .= '[]';
            }
            $output .= '" value="' . $option['value'] . '"';
            if (isset($option['checked'])) {
                $output .= ' checked';
            }
            $output .= '>';
        }
        return $output;
    }