Reputation: 2587
I have made a custom module and it works fine till I start working on my custom theme.
Once I move over to my custom theme I get this error
Warning: Missing argument 2 for customvishal_form(), called in /home/vishal/Dropbox/sites/new/includes/theme.inc on line 1029 and defined in customvishal_form() (line 441 of /home/vishal/Dropbox/sites/new/sites/all/modules/customvishal/customvishal.module).
You can see the error at : http://www.iamvishal.com/dev/about-us
I don't think anything is wrong with my code :
/**
* A simple form.
*/
function customvishal_form($form, &$form_submit) {
$form['customvishalactivate'] = array(
'#title' => t('Activate Preference'),
'#type' => 'radios',
'#options' => array('1' => t('Yes'), '0' => t('No')),
'#required' => TRUE,
);
return $form;
}
Its called from
function customvishal_pref($arg1)
{
// Here we willl make the form and save the data so when cron
// runs we will check the users preference
$build = array(
'header_text' => array(
'#type' => 'markup',
'#markup' => '<p>' . t('This page is where you add your preferences. Based on your
entered choices we will send you alerts ') . '</p>',
),
'example_form' => drupal_get_form('customvishal_form'),
);
return $build;
}
What might be causing this problem ?
Cheers, Vishal
Upvotes: 1
Views: 2674
Reputation: 821
I had the same issue
I called hook_form like this:
/** * Implements of hook_menu(). */ function skupina_menu() { $items = array(); $items['admin/config/people/skupina'] = array( 'title' => 'Skupiny odborníkov', 'description' => 'Prehľady návštev odborníkov', 'page callback' => 'drupal_get_form', 'page arguments' => array('skupina_statistics'), 'access arguments' => array('view statistics'), 'file' => 'admin.inc', 'file path' => drupal_get_path('module', 'skupina'), 'weight' => 1, ); return $items; }
and then
/** * Prehlad navstev odbornikov - page */ function skupina_statistics($form, &$form_state) { $form = array(); $form['skupina_obdobie'] = array( '#type' => 'select', '#title' => t('Zmeniť zobrazenie'), '#options' => skupina_get_zobrazenia(), '#description' => t('Zmení filtrovanie dát podľa zvolenej možnosti.'), '#required' => FALSE, ); return $form; }
my problem was, that the function didn't have the "_form" in its name so its produce those warnings.
So the function must be called "skupina_statistics_form
in my case
Upvotes: 3
Reputation: 11
I think I know the answer. I had the exact same problem.
Is your module named exactly as your custom theme? Mine was and I changed my theme name and the error went away
Upvotes: 1
Reputation: 275
when the form function is called the only parameter that is sent to it is the form variable. Since your second function parameter doesn't have a default value it obviously produces a warning.
If you never use it in the function code you might consider removing it or providing a default value.
e.g.:
function customvishal_form($form, &$form_submit = NULL)
or you might consider passing an additional parameter. You can do this like so:
drupal_get_form('customvishal_form', $some_your_parameter);
Upvotes: 2