/** * @param string $property The model option property * @param array $atts @see PW_HTML::tag() for details * @param string $unchecked_value An optional default value in case the box is left unchecked * @param string $extra Any addition markup you want to display after the input element * @return string The generated HTML markup * @since 0.1 */ public function checkbox($property, $atts = array(), $unchecked_value = null, $extra = '') { extract($this->get_field_data_from_model($property)); // returns $error, $label, $name, $value, $id // Make sure value is set (default to "1") $atts['value'] = isset($atts['value']) ? $atts['value'] : "1"; // Determine if the checkbox should be selected $selected = $value == $atts['value']; $field = PW_HTML::checkbox($name, $selected, $atts, $unchecked_value) . PW_HTML::label($desc, $id); // set the $desc value to '' because the checkbox is already using it for generate the label $this->return_or_echo($this->render_field($label, $field, '', $extra, $error)); }