form_radios

Versions
4.6
form_radios($title, $name, $value, $options, $description = NULL, $required = FALSE, $attributes = NULL)

Format a set of radio buttons.

Parameters

$title The label for the radio buttons as a group.

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

$value The currently selected radio button's key.

$options An associative array of buttons to display. The keys in this array are button values, while the values are the labels to display for each button.

$description Explanatory text to display after the form item.

$required Whether the user must select a radio button before submitting the form.

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

Return value

A themed HTML string representing the radio button set.

Related topics

▾ 23 functions call form_radios()

aggregator_settings in modules/aggregator.module
block_admin_configure in modules/block.module
Menu callback; displays the block configuration form.
block_admin_display in modules/block.module
Prepare the main block administration form.
comment_admin_edit in modules/comment.module
Menu callback; edit a comment from the administrative interface.
comment_configure in modules/comment.module
Menu callback; presents the comment settings page.
comment_nodeapi in modules/comment.module
Implementation of hook_nodeapi().
drupal_settings in modules/drupal.module
Implementation of hook_settings().
forum_admin_configure in modules/forum.module
Implementation of hook_settings
locale_user in modules/locale.module
Implementation of hook_user().
node_configure in modules/node.module
Menu callback; presents general node configuration options.
poll_form in modules/poll.module
Implementation of hook_form().
poll_view_voting in modules/poll.module
Generates the voting form for a poll.
statistics_settings in modules/statistics.module
Implementation of hook_settings().
system_view_general in modules/system.module
taxonomy_form_vocabulary in modules/taxonomy.module
upload_nodeapi in modules/upload.module
Implementation of hook_nodeapi().
user_configure_settings in modules/user.module
user_edit_form in modules/user.module
_filter_html_settings in modules/filter.module
Settings for the HTML filter.
_locale_admin_import_screen in includes/locale.inc
User interface for the translation import screen
_locale_string_seek_form in includes/locale.inc
User interface for the string search screen
_profile_field_form in modules/profile.module
_user_admin_access_form in modules/user.module

Code

includes/common.inc, line 1123

<?php
function form_radios($title, $name, $value, $options, $description = NULL, $required = FALSE, $attributes = NULL) {
  if (count($options) > 0) {
    $choices = '';
    foreach ($options as $key => $choice) {
      $choices .= '<label class="option"><input type="radio" class="form-radio" name="edit['. $name .']" value="'. check_plain($key) .'"'. ($key == $value ? ' checked="checked"' : ''). drupal_attributes($attributes) .' /> '. $choice .'</label><br />';
    }
    return theme('form_element', $title, $choices, $description, NULL, $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.