How can I theme custom form(drupal 6.x)
Posted
by Andrew
on Stack Overflow
See other posts from Stack Overflow
or by Andrew
Published on 2010-05-24T17:35:03Z
Indexed on
2010/05/24
18:21 UTC
Read the original article
Hit count: 212
DRUPAL 6.X
I have this custom form constructor inside my custom module which is invoke through ajax request. I’m attempting to theme this form with the template file reside in my theme directory. For that matter, I’ve registered my theme inside template.php file which reside in my theme folder. Here’s how this file looks –
function my_theme() {
return array(
'searchdb' => array(
'arguments' => array('form' => NULL),
'template' => 'searchform',
)
);
}
And the following is the excerpt of module code –
function test_menu() {
$my_form['searchdb'] = array(
'title' => 'Search db',
'page callback' => 'get_form',
'page arguments' => array(0),
'access arguments' => array('access content'),
'type' => MENU_CALLBACK,
);
return $my_form;
}
function get_form($formtype){
switch($formtype){
case 'searchdb' :
echo drupal_get_form('searchdb');
break;
}
}
function searchdb(){
$form['customer_name'] = array(
'#type' => 'textfield',
'#title' => t('Customer Name'),
'#size' => 50,
'#attributes' => array('class' => 'name-textbox'),
);
return $form;
}
As you can imagine, this is not working at all. Just to test if my theme is even registered, I’ve also tested with theme function but, it’s not called. I've checked template file name and form-id(through the outputted html source) and everything seems ok. I would be glad if anyone could point me to the right direction.
© Stack Overflow or respective owner