concrete/src/Form/Service/Form.php
public function checkbox($key, $value, $isChecked = false, $miscFields = [])
    {
        if (substr($key, -2) == '[]') {
            $_field = substr($key, 0, -2);
            $id = $_field . '_' . $value;
        } else {
            $_field = $key;
            $id = $key;
        }

        $checked = false;
        if ($isChecked && $this->getRequest()->get($_field) === null && $this->getRequest()->getMethod() !== 'POST') {
            $checked = true;
        } else {
            $requestValue = $this->getRequestValue($key);
            if ($requestValue !== false) {
                if (is_array($requestValue)) {
                    if (in_array($value, $requestValue)) {
                        $checked = true;
                    }
                } elseif ($requestValue == $value) {
                    $checked = true;
                }
            }
        }
        $checked = $checked ? ' checked="checked"' : '';

        return '<input type="checkbox" id="' . $id . '" name="' . $key . '"' . $this->parseMiscFields('ccm-input-checkbox', $miscFields) . ' value="' . $value . '"' . $checked . ' />';
    }
public function checkbox($key, $value, $isChecked = false, $miscFields = [])
    {
        if (substr($key, -2) == '[]') {
            $_field = substr($key, 0, -2);
            $id = $_field . '_' . $value;
        } else {
            $_field = $key;
            $id = $key;
        }

        $checked = false;
        if ($isChecked && $this->getRequest()->get($_field) === null && $this->getRequest()->getMethod() !== 'POST') {
            $checked = true;
        } else {
            $requestValue = $this->getRequestValue($key);
            if ($requestValue !== false) {
                if (is_array($requestValue)) {
                    if (in_array($value, $requestValue)) {
                        $checked = true;
                    }
                } elseif ($requestValue == $value) {
                    $checked = true;
                }
            }
        }
        $checked = $checked ? ' checked="checked"' : '';

        return '<input type="checkbox" id="' . $id . '" name="' . $key . '"' . $this->parseMiscFields('ccm-input-checkbox', $miscFields) . ' value="' . $value . '"' . $checked . ' />';
    }
public function checkbox ( $ key , $ value , $ isChecked = false , $ miscFields = [ ] ) { if ( substr ( $ key , - 2 ) == '[]' ) { $ _field = substr ( $ key , 0 , - 2 ) ; $ id = $ _field . '_' . $ value ; } else { $ _field = $ key ; $ id = $ key ; } $ checked = false ; if ( $ isChecked && $ this -> getRequest ( ) -> get ( $ _field ) === null && $ this -> getRequest ( ) -> getMethod ( ) !== 'POST' ) { $ checked = true ; } else { $ requestValue = $ this -> getRequestValue ( $ key ) ; if ( $ requestValue !== false ) { if ( is_array ( $ requestValue ) ) { if ( in_array ( $ value , $ requestValue ) ) { $ checked = true ; } } elseif ( $ requestValue == $ value ) { $ checked = true ; } } } $ checked = $ checked ? ' checked="checked"' : '' ; return '<input type="checkbox" id="' . $ id . '" name="' . $ key . '"' . $ this -> parseMiscFields ( 'ccm-input-checkbox' , $ miscFields ) . ' value="' . $ value . '"' . $ checked . ' />' ; }
Generates a checkbox.

@param string $key The name/id of the element. It should end with '[]' if it's to return an array on submit.
@param string $value String value sent to server, if checkbox is checked, on submit
@param string $isChecked "Checked" value (subject to be overridden by $_REQUEST). Checkbox is checked if value is true (string). Note that 'false' (string) evaluates to true (boolean)!
@param array $miscFields additional fields appended to the element (a hash array of attributes name => value), possibly including 'class'

@return string
Generates a checkbox .