Thanks to everyone who helped before. I have created my module, installed the new tables for the custom node type with the schema and declared all the form fields using the API. It works fine if I use drupal-get-form, but I need to override the default layout with a custom theme. This is where I keep running into trouble. I have declared the theme using hook_theme and have written a custom theme function (theme_jobapp) and I need to call the new node from a menu item. I have tried every possible combination I can think of to make this work.
My question is: How do I tell Drupal to use my theme and my form definition in a Menu callback?????
Please see below for a list of combinations and errors and code.
- If I use drupal_get_form for the page callback - I don't get my custom theme.
- If I pass the name of my custom theme as a page argument I get the following error:
Fatal error: Cannot unset string offsets in /Users/myhomefolder/Sites/drupal-6.x/includes/form.inc on line 491 - If I call my theme function as the page callback, I get my theme but the fields don't show up - just the external html.
- If I call my theme function as the page callback, pass nothing in page arguments in the menu hook and pass ($form) to the theme function I get this error:
warning: Missing argument 1 for theme_jobapp() in /Users/myhomefolder/Sites/drupal-6.x/sites/mysite.drupal.local/modules/jobapp/jobapp.inc on line 1279. (theme_jobapp($form)) - If I call my theme function as the page callback, pass $form in the page arguments in the menu hook and pass ($form) to the theme function I don't get an error but I also don't get any fields.
- If I call my theme function as the page callback, pass the name of my form function in the page arguments in the menu hook and pass ($form) to the theme function I get this error:
Fatal error: Only variables can be passed by reference in /Users/myhomefolder/Sites/drupal-6.x/sites/mysite.drupal.local/modules/jobapp/jobapp.inc on line 1316
($output .= drupal_render($form['LastName']);) - If I call my theme function as the page callback, pass the name of my form function in the page arguments in the menu hook and pass nothing to the theme function I don't get an error but I also don't get any fields.
- If I call my theme function as the page callback, pass the name of my module in the page arguments in the menu hook and pass nothing to the theme function I don't get an error but I also don't get any fields.
Its seems to me that Drupal isn't identifying my form definitions when rendering the form.
Here's some of the code:
function jobapp_theme() {
return array(
'jobapp' => array(
'arguments' => array('theme_jobapp'),
),
);
}then the theme itself goes something like this:
function theme_jobapp(){
$output = custom layout stuff;
$output .= drupal_render($form['LastName']);
$output .= drupal_render($form['FirstName']);
$output .= drupal_render($form['MI']);
etc, etc
return $output;
}the Menu callback looks like this:
function jobapp_menu(){
$items = array();
$items['jobapp/add'] = array(
'title' => 'Apply to XXXXX',
'description' => t('Creates a new job application for the current user.'),
'page callback' => 'theme_jobapp',
'page arguments' => array('form_jobapp'),//arguments to pass
'file' => 'jobapp.inc',
'access arguments' => array('access jobapp'),
'type' => MENU_CALLBACK,
);