PHPJavascript

Web Development Guide – My Personal Library of Tutorials and Scripts

Drupal Forms API checkboxes example basic

November9

I am learning to develop modules in drupal, and intend to document my learning process.

So here it is basic clear example of how to add checkboxes to your form in the admin settings page of your module:

function onthisdate_admin() {
$form['fd_boxes'] = array
(
'#type'            => 'checkboxes',
'#options'         => array
(
15 => 'a',
20 => 'b',
25 => 'c',
),
'#default_value'   => variable_get('fd_boxes', 0),
);
return system_settings_form($form);
}

Click here for my source and further details

Note: “onthisdate” is the name of my test module. Rename it to your module name. If you are new to module development, click here to get the basic info.

posted under Drupal

Email will not be published

Website example

Your Comment:

 

12,958 spam comments
blocked by
Akismet