使用帶 checkboxes 的表格

1 篇文章 / 0 new
author
使用帶 checkboxes 的表格
 // print drupal_render(drupal_get_form('example_ckform'));
function example_ckform() {//表格式選項
    $users = array(
        array('uid' => 1, 'first_name' => 'Indy', 'last_name' => 'Jones'),
        array('uid' => 2, 'first_name' => 'Darth', 'last_name' => 'Vader'),
        array('uid' => 3, 'first_name' => 'Super', 'last_name' => 'Man'),
    );
    $header = array(
        'first_name' => t('First Name'),
        'last_name' => t('Last Name'),
    );
    $options = array();
    foreach ($users as $user) {
        $options[$user['uid']] = array(
            'first_name' => $user['first_name'],
            'last_name' => $user['last_name'],
        );
    }
    $form['table'] = array(
        '#type' => 'tableselect',
        '#header' => $header,
        '#options' => $options,
        '#empty' => t('No users found'),
    );
}
from https://drupal.org/node/945102
Free Web Hosting