Hi,
(Considere Planes is my module)
I develop a module who it has 2 node types. I write correctly node_info hook and I use switch...case to generate form into planes_form(&$node) on $node->type.

My two types names are:

  • planes
  • planes_fields

But when I go to edit page, this error goes :
warning: call_user_func_array() [function.call-user-func-array]: First argument is expected to be a valid callback, 'planes_node_form' was given in /.././///

Maybe I don't use correct method when a module has many nodes types.

Thanks for your help.

Comments

jamestombs’s picture

You should be able to do it like this:

function planes_node_info() {
	return array(
		'planes' => array(
			'name' => t('Planes'),
			'module' => 'planes',
			'description' => t('Add a new slide.'),
			'had_title' => TRUE,
			'title_label' => t('Title'),
			'had_body' => TRUE,
			'body_label' => t('Body'),
			'min_word_count' => 2,
			'locked' => TRUE,
		),
                'planes_fields' => array(
			'name' => t('Planes Fields'),
			'module' => 'planes',
			'description' => t('Add a new slide.'),
			'had_title' => TRUE,
			'title_label' => t('Title'),
			'had_body' => TRUE,
			'body_label' => t('Body'),
			'min_word_count' => 2,
			'locked' => TRUE,
		),
	);
}

Then in your hook_form(). Have:

function planes_form(&$form) {
   $type = $form->type;
   switch ($type) {
       case 'planes':
            // form code
            return $form;
       case 'planes_fields':
           // form code
           return $form;
   }
}

I think, I am new to Drupal.

Action Medical Research - www.action.org.uk

James T
Action Medical Research - www.action.org.uk

lphm’s picture

Your response help me :).

Thanks.