form_checkbox

Versions
4.6
form_checkbox($title, $name, $value = 1, $checked = FALSE, $description = NULL, $attributes = NULL, $required = FALSE)

Format a checkbox.

Parameters

$title The label for the checkbox.

$name The internal name used to refer to the button.

$value The value that the form element takes on when selected.

$checked Whether the button will be initially selected when the page is rendered.

$description Explanatory text to display after the form item.

$attributes An associative array of HTML attributes to add to the button.

$required Whether the user must check this box before submitting the form.

Return value

A themed HTML string representing the checkbox.

Related topics

▾ 26 functions call form_checkbox()

block_admin_display in modules/block.module
Prepare the main block administration form.
block_user in modules/block.module
Implementation of hook_user().
contact_user in modules/contact.module
Implementation of hook_user().
filter_admin_filters in modules/filter.module
Menu callback; configure the filters for a format.
filter_admin_overview in modules/filter.module
Menu callback; allows administrators to set up input formats.
forum_form in modules/forum.module
Implementation of hook_form().
hook_settings in developer/hooks/core.php
Declare administrative settings for a module.
menu_edit_item_form in modules/menu.module
Present the menu item editing form.
nodeapi_example_nodeapi in developer/examples/nodeapi_example.module
Implementation of hook_nodeapi().
node_access_example_nodeapi in developer/examples/node_access_example.module
Implementation of hook_nodeapi().
node_admin_nodes in modules/node.module
Generate the content administration overview.
node_form in modules/node.module
Generate the node editing form.
poll_form in modules/poll.module
Implementation of hook_form().
profile_form_profile in modules/profile.module
queue_settings in modules/queue.module
system_module_listing in modules/system.module
Generate a list of all the available modules, as well as update the system list.
system_theme_listing in modules/system.module
Generate a list of all the available theme/style combinations.
system_theme_settings in modules/system.module
Menu callback; display theme configuration for entire site and individual themes.
taxonomy_form_vocabulary in modules/taxonomy.module
upload_form in modules/upload.module
user_admin_perm in modules/user.module
Menu callback: administer permissions.
user_edit_form in modules/user.module
_aggregator_page_list in modules/aggregator.module
Prints an aggregator page listing a number of feed items. Various menu callbacks use this function to print their feeds.
_filter_html_settings in modules/filter.module
Settings for the HTML filter.
_locale_admin_manage_screen in includes/locale.inc
User interface for the language management screen
_profile_field_form in modules/profile.module

Code

includes/common.inc, line 1153

<?php
function form_checkbox($title, $name, $value = 1, $checked = FALSE, $description = NULL, $attributes = NULL, $required = FALSE) {
  $element = '<input type="checkbox" class="'. _form_get_class('form-checkbox', $required, _form_get_error($name)) .'" name="edit['. $name .']" id="edit-'. $name .'" value="'. check_plain($value) .'"'. ($checked ? ' checked="checked"' : '') . drupal_attributes($attributes) .' />';
  if (!is_null($title)) {
    $element = '<label class="option">'. $element .' '. $title .'</label>';
  }
  // Note: because unchecked boxes are not included in the POST data, we include
  // a form_hidden() which will be overwritten for a checked box.
  return form_hidden($name, 0) . theme('form_element', NULL, $element, $description, $name, $required, _form_get_error($name));
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.