So I’ve been following this tutorial http://drupal.org/node/751826. I took the following code:
<?php
function test_myform(&$form_state) {
// Access log settings:
$options = array('1' => t('Enabled'), '0' => t('Disabled'));
$form['access'] = array(
'#type' => 'fieldset',
'#title' => t('Access log settings'),
'#tree' => TRUE,
);
$form['access']['log'] = array(
'#type' => 'radios',
'#title' => t('Log'),
'#default_value' => variable_get('log', 0),
'#options' => $options,
'#description' => t('The log.'),
);
$period = drupal_map_assoc(array(3600, 10800, 21600, 32400, 43200, 86400, 172800, 259200, 604800, 1209600, 2419200, 4838400, 9676800), 'format_interval');
$form['access']['timer'] = array(
'#type' => 'select',
'#title' => t('Discard logs older than'),
'#default_value' => variable_get('timer', 259200),
'#options' => $period,
'#description' => t('The timer.'),
);
// Description
$form['details'] = array(
'#type' => 'fieldset',
'#title' => t('Details'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['details']['description'] = array(
'#type' => 'textarea',
'#title' => t('Describe it'),
'#default_value' => variable_get('description', ''),
'#cols' => 60,
'#rows' => 5,
'#description' => t('Log description.'),
);
$form['details']['admin'] = array(
'#type' => 'checkbox',
'#title' => t('Only admin can view'),
'#default_value' => variable_get('admin', 0),
);
$form['name'] = array(
'#type' => 'textfield',
'#title' => t('Name'),
'#size' => 30,
'#maxlength' => 64,
'#description' => t('Enter the name for this group of settings'),
);
$form['hidden'] = array('#type' => 'value', '#value' => 'is_it_here');
$form['submit'] = array('#type' => 'submit', '#value' => t('Save'));
return $form;
}
function test_page() {
return drupal_get_form('test_myform');
}
?>
I pasted this code into my text field. At the end, before the php close tag, I called the function test_page as following
test_page();
I get the following error after I save.
Warning: Parameter 1 to test_myform() expected to be a reference, value given in drupal_retrieve_form() (line 785 of /var/www/html/includes/form.inc).
Warning: Parameter 1 to test_myform() expected to be a reference, value given in drupal_retrieve_form() (line 785 of /var/www/html/includes/form.inc).
Now I have no idea why. Basically what I’m trying to do is create a webform and save it locally on the server. If you guys have any other ideas besides using the Drupal Form API, I’m welcome to suggestions.
Any help would be greatly appreciated.
Try changing the arguments in your test_myform() function to the following
Does that do it?
Adding to answer after your comment:
I’m not sure where and how you’re calling your function, so I can’t help much. Why don’t you just get rid of that test_page() function and call the drupal form from a menu item.
So, in your module, just have the following menu hook:
To test it out, make sure you 1) enable your module, 2) flush all caches so the menu is rebuilt and 3) go to whatever you replace that menu item with, in this example it would be http://www.yoursite.com/test/page or localhost/test/page. I think that’s a better way to call your form function — through the menu.
Does that work?