Rose::HTML::Form::Field::Checkbox(3p)

NAME
Rose::HTML::Form::Field::Checkbox - Object representation of a single checkbox field in an HTML form.

SYNOPSIS
    $field =
      Rose::HTML::Form::Field::Checkbox->new(
        label => 'Run tests',
        name  => 'tests',
        value => 'yes');

    $checked = $field->is_checked; # false

    $field->checked(1);

    print $field->html;

    ...

DESCRIPTION
Rose::HTML::Form::Field::Checkbox is an object representation of a single checkbox field in an HTML form.

This class inherits from, and follows the conventions of, Rose::HTML::Form::Field. Inherited methods that are not overridden will not be documented a second time here. See the Rose::HTML::Form::Field documentation for more information.

HTML ATTRIBUTES
Valid attributes:

    accept
    accesskey
    checked
    class
    dir
    disabled
    id
    lang
    maxlength
    name
    onblur
    onchange
    onclick
    ondblclick
    onfocus
    onkeydown
    onkeypress
    onkeyup
    onmousedown
    onmousemove
    onmouseout
    onmouseover
    onmouseup
    onselect
    readonly
    size
    style
    tabindex
    title
    type
    value
    xml:lang

Required attributes (default values in parentheses):

    type (checkbox)
    value

Boolean attributes:

    checked
    disabled
    readonly

CONSTRUCTOR

new PARAMS
    Constructs a new Rose::HTML::Form::Field::Checkbox object based on PARAMS, where PARAMS are name/value pairs. Any object method is a valid parameter name.

OBJECT METHODS

checked [BOOL]
    Check or uncheck the checkbox by passing a boolean value. If BOOL is true, the checkbox will be checked. If it is false, it will be unchecked. Returns true if the checkbox is checked, false otherwise.

hidden [BOOL]
    Get or set a boolean value that indicates whether or not this checkbox will be shown in its parent checkbox group. Setting it to true also sets checked to false.

hide
    Calls hidden, passing a true value.

html_checkbox
    Returns the HTML serialization of the checkbox field only (i.e., without any label or error message)

is_checked
    Returns true if the checkbox is checked, false otherwise.

is_on
    Simply calls is_checked. This method exists for API uniformity between radio buttons and checkboxes.

show
    Calls hidden, passing a false value.

value [VALUE]
    Gets or sets the value of the "value" HTML attribute.

xhtml_checkbox
    Returns the XHTML serialization of the checkbox field only (i.e., without any label or error message)

AUTHOR
John C. Siracusa (siracusa@gmail.com)

LICENSE
Copyright (c) 2009 by John C. Siracusa. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.