By r3z0nate on
Using as much as I could from the example code, documentation and admin modules, I built a form and need to apply a theme to it. I believe I'm using all of the proper syntax to populate the form, I just can't pass it to the theme_myform function.
I've had problems displaying the page and need the proper settings for hook_theme and hook_menu when outputting a form this way.
Optionally, if I could just display a form without using a table it would solve my problems. Here is the code..
function my_theme() {
return array(
'theme_myadmin_form' => array(
'arguments' => array('form' => NULL),
'file' => 'myadmin_form.inc', ),
'myadmin_form' => array(
'arguments' => array('form' => NULL),
'file' => 'myadmin_form.inc',
),
);
}
$items['admin/myform'] = array(
'title' => 'Title',
'description' => "Desc",
'page callback' => 'drupal_get_form',
'page arguments' => array('myadmin_form', NULL),
'access arguments' => array('administer modules'),
'file' => 'myform.inc',
);
function myadmin_form(&$formstate) {
$row = array();
$row[] = $form['option'] = array('#type'=>'hidden','#value' =>'');
$row[] = $form['field1'] = array('#type'=>'text','#value' =>'');
$rows[] = $row;
$header = array(t('Header'));
$form['myadmin'] = array('#value' => theme('table', $headers, $rows));
return $form;
}
function theme_myadmin_form($form) {
$output=drupal_get_form('myadmin_form');
return $output;
}
Comments
Use the #theme directive
Hi,
Separate the form definition code from the theme code.
Add a #theme directive to your myadmin_form() method. For examples,
$form['#theme'] = 'theme_myadmin_form';. http://api.drupal.org/api/drupal/developer--topics--forms_api_reference....Move the html table routine in to the theme_myadmin_form() method (
theme('table', $headers, $rows));).Check this doc page : http://drupal.org/node/112358