so here is my hook form for a module i'm making with a node called conferences, when i call http://mysite.com/node/add/conferences i get the form to display and can add the node. However, after i have submitted the node and go to edit i get the following error:

warning: array_merge_recursive() [function.array-merge-recursive]: Argument #2 is not an array in /path/to/drupal/install/modules/node.module on line 1665.

i've done some searching and as far as i can tell this is the hook that should be called, however it doesn't get called or for some reason no array goes back to the calling function and therefore i get this warning. I'm fairly new to drupal, even newer to writing my own module. I'd appreciate any help, or anyone that might be able to point me in the right direction. If you need to know anything else about my code let me know.

function conferences_form(&$node, &$param)
{
        //Conference name / Journal Name
        $form['title'] = array(
                '#type' => 'textfield',
                '#title' => t('conference/journal name'),
                '#required' => TRUE,
                '#defualt_value' => $node->title,
                '#weight' => -5,
                '#description' => t('Full name of conference or journal')
        );

        //conference short name
        $form['shortname'] = array(
                '#type' => 'textfield',
                '#title' => t('conference/journal shortname'),
                '#required' => TRUE,
                '#defualt_value' => $node->shortname,
                '#weight' => -4,
                '#description' => t('short name of conference or journal/repeat full name if no short name')
        );

        //Description/Comments
        $form['body_filter']['body'] = array(
                '#type' => 'textarea',
                '#title' => t('Description'),
                '#required' => FALSE,
                '#defualt_value' => $node->body,
                '#rows' => 10,
                '#weight' => -3,
                '#description' => t('Short Description of the Conference')
        );
        $form['body_filter']['format'] = filter_form($node->format);

        //year
        $form['year'] = array(
                '#type' => 'textfield',
                '#title' => t('Conference Year'),
                '#required' => FALSE,
                '#defualt_value' => $node->year,
                '#weight' => -2,
                '#description' => t('Format YYYY'),
                '#size' => 4
        );

        //type
        $types = _conferences_types();
        $form['sub_type'] = array(
                '#type' => 'select',
                '#title' => t('Venue Type'),
                '#required' => TRUE,
                '#defualt_value' => $node->sub_type,
                '#options' => $types,
                '#weight' => -1
        );

        //Due Date
        $form['duedate'] = array(
                '#type' => 'textfield',
                '#title' => t('Due Date'),
                '#required' => FALSE,
                '#default_value' => $node->duedate,
                '#weight' => 0,
                '#description' => t('Format dd/mm/yyyy')
        );

        //Conference Date
        $form['conferencedate'] = array(
                '#type' => 'textfield',
                '#title' => t('Conference Date'),
                '#required' => FALSE,
                '#default_value' => $node->conferencedate,
                '#weight' => 1,
                '#description' => t('Format dd/mm/yyyy')
        );

        //Venue
        $form['venue'] = array(
                '#type' => 'textfield',
                '#title' => t('Venue'),
                '#required' => FALSE,
                '#default_value' => $node->venue,
                '#weight' => 2,
                '#description' => t('Enter the venue for the conference/journal')
        );

        //Link
        $form['link'] = array(
                '#type' => 'textfield',
                '#title' => t('Link'),
                '#required' => FALSE,
                '#default_value' => $node->link,
                '#weight' => 3,
                '#description' => t('Link to the conference or journal website')
        );

        //Submission Type
        $submissionType = _conferences_submissionTypes();
        $form['submissiontype'] = array(
                '#type' => 'select',
                '#title' => t('Submission Type'),
                '#required' => TRUE,
                '#defualt_value' => $node->submissiontype,
                '#options' => $submissionType,
                '#weight' => 4
        );

        return $form;
}

Comments

step3hand’s picture

I don't know what your issue is, but I don't believe it has anything to do with the code you just inserted.

I think you should paste in your _menu function as well as any functions related to your "add" callback. I still probably won't be able to help, but maybe with that info, someone else will.

mpare’s picture

What does your hook_node_info look like? If its as you say and the function's not getting called then maybe there is a name set wrong in hook_node_info. then I always place <?php $type = node_get_types('type', $node); ?> inside my hook_form.

One first glance that's what came to mind, hope it proves fruitful.

Peace,
-mpare
--
Pare Technologies
Drupal Consulting, Themeing, and Module Development
806.781.8324 | 806.733.3025
www.paretech.com

Figure Something Out? Document Your Success!

codewrighter’s picture

function conferences_node_info()
{
        return array('conferences' => array('name' => t('Conference'), 'base' => 'conferences'));
}

function conferences_menu($may_cache)
{
        $items = array();

        if($may_cache)
        {
                $items[] = array('path' => 'conferences', 'title' => t('Conferences'), 'callback' => 'conferences_all', 'access' => user_access('access conferences'), 'type' => MENU_CALLBACK);
                $items[] = array('path' => 'node/add/conference', 'title' => t('conferences'), 'access' => user_access('create conferences'));
        }
        return $items;
}

So there is the code you asked for, I'm totally new to coding modules, so i honestly have no idea what is going on with this problem. I have a fairly good idead of what is happening in drupal, but i appreciate your help.

mpare’s picture

If this is a node form you will want to use node_add as the call back and the argument would be your node form in an array, array('conferences'). By default drupal will create one menu hook properly for node forms in the create content page.

<?php
    $items[] = array(
      'title' => t('Conferences'),
      'path' => 'conferences/new',
      'callback' => 'node_add',
      'callback arguments' => array('conferences'),
      'type' => MENU_CALLBACK,
      'access' => TRUE,
    );
?>

Alternatively if this is not a node form you would use drupal_get_form, but from my initial light observations this is a node form so the above should work for you unless there are other problems.

Peace,
-mpare
--
Pare Technologies
Drupal Consulting, Themeing, and Module Development
806.781.8324 | 806.733.3025
www.paretech.com

Figure Something Out? Document Your Success!

codewrighter’s picture

this is for when i want to call node/conferences/add correct? I will do that, but that seems to work correctly already, the problem that i run into is when i want to call node/nodenumber/edit, then it gives me that error. Anyway, thanks i'll give that i try and get back to you.