### Options:
- value - the value of the checkbox
- checked - boolean indicate that this checkbox is checked.
- hiddenField - boolean to indicate if you want the results of checkbox() to include
a hidden input with a value of ''.
- disabled - create a disabled input.
- default - Set the default value for the checkbox. This allows you to start checkboxes
as checked, without having to check the POST data. A matching POST data value, will overwrite
the default value.
/** * Creates a checkbox input element * @param string $fieldName Field name, should be "Modelname.fieldname" * @param array $options HTML attributes and options * @return string */ public function checkbox($fieldName, array $options = []) { if (!isset($options['hiddenField']) || !empty($options['hiddenField'])) { $options['hiddenField'] = true; } return parent::checkbox($fieldName, $options); }
/** * Create and render ace checkbox. * * @param string $fieldName * @param array $options * @return array|string */ public function checkbox($fieldName, array $options = []) { $viewForm = $this->_View->Form; $options = $this->addClass($options, 'ace'); if (is_object($viewForm->_context)) { if (!is_null($viewForm->_context->val($fieldName))) { $options['val'] = $viewForm->_context->val($fieldName); } if (!in_array($fieldName, $viewForm->fields)) { $this->_View->Form->fields[] = $fieldName; } } return parent::checkbox($fieldName, $options); }