Hello!
I read about theming forms at http://api.drupal.org/api/file/developer/topics/forms_api.html/6
Now I tried this for myself inside my own module.
But I get strange results. First, the submit button in the fieldset is above the textfield, although I expected it the other way around (cause I first rendered textfield and then the submit button).
Also I get those five <br>'s below the fieldset, although I rendered it in between.
Second, I get an error message (warning: implode() [function.implode]: Bad arguments. in /var/www/medicalgenomics_drupal/includes/form.inc on line 621.)
What am I doing wrong? Can't find a really good example code.
Here my code:
/* $Id$ */
function blotbase_search_perm() {
return array('access blotbase_search');
}
function _main() {
//$content = drupal_get_form('_query_form');
$content = theme_query_form(_query_form());
return $content;
}
function _query_form() {
$form["fulltext_search"] = array(
'#type' => 'fieldset',
'#title' => t('Search BlotBase'),
);
$form["fulltext_search"]["action"] = array(
'#type' => 'hidden',
'#value' => 'query',
);
$form["fulltext_search"]["query_string"] = array(
'#type' => 'textfield',
'#title' => t('Search for a gene symbol resp. identifier and/or paper title/author'),
'#default_value' => '',
'#size' => 60,
'#maxlength' => 64,
'#description' => t('baz'),
);
$form["fulltext_search"]["submit"] = array(
'#type' => 'submit',
'#value' => t('Search'),
);
return $form;
}
function theme_query_form($form) {
$output = '';
$output .= drupal_render($form["fulltext_search"]);
$output .= drupal_render($form["fulltext_search"]["query_string"]);
$output .= '<br><br><br><br><br>';
$output .= drupal_render($form["fulltext_search"]["submit"]);
$output .= drupal_render($form);
return $output;
}
function blotbase_search_menu() {
$items[] = array(
'path' => 'databases/blotbase',
'title' => 'Search BlotBase',
'callback' => '_main',
'access' => user_access('access blotbase_search'),
'type' => MENU_CALLBACK,
);
return $items;
}
Comments
I would be interested in
I would be interested in inputs about form theming.
Shyamala
Team Leader Netlink Technologies Ltd.
Shyamala
http://www.unimitysolutions.com
bump
bump
Your running
Your running
drupal_render($form["fulltext_search"])
*first* and "fulltext_search" contains your field and button so those will be rendered.drupal_render remembers what's been rendered already so remove that first call and it should work.