// hook_user
function mymodule_user($op, &$edit, &$account, $category = NULL) {
switch ($op) {
case 'categories':
$output[] = array(
'name' => 'new_category',
'title' => t('new_category'),
);
case 'form':
if ($category == 'new_category') {
$form_state = array();
$form = mymodule_new_category_form($form_state, $account);
return $form;
}
break;
}
}
function mymodule_new_category_form(&$form_state, $account) {
$form = array();
$form['new_category'] = array(
'#type' => 'fieldset',
'#title' => t('new_category'),
'#theme' => 'mymodule_new_category_form',
);
$form['new_category']['text1'] = array(
'#type' => 'textfield',
'#title' => t('text1'),
);
$form['new_category']['text2'] = array(
'#type' => 'textfield',
'#title' => t('text2'),
);
$form['new_category']['text3'] = array(
'#type' => 'textfield',
'#title' => t('text3'),
);
return $form;
}
// hook_theme
function mymodule_theme() {
return array(
'mymodule_new_category_form' => array(
'arguments' => array('form' => NULL),
),
);
}
function theme_mymodule_new_category_form($form) {
$rows = array();
foreach (element_children($form) as $form_field_name) {
$description = $form[$form_field_name]['#description'];
$form[$form_field_name]['#description'] = '';
$title = theme('form_element', $form[$form_field_name], '');
$form[$form_field_name]['#description'] = $description;
$form[$form_field_name]['#title'] = '';
$row = array(
'data' => array(
0 => array('data' => $title, 'class' => 'label_cell'),
1 => drupal_render($form[$form_field_name])
)
);
$rows[] = $row;
}
$output = theme('table', array(), $rows);
$output .= drupal_render($form);
return $output;
}