4

I'm using panels to create a single page that will display multiple (different) node add forms. Within panels, I use contexts to activate the node add forms I'm using and then put the forms in as content. However, the resulting page shows only the first node add form and then displays "Form" and "Form goes here" in place of the Title and fields of the second node add form.

Is there a fix for this? Or another way to display multiple node add forms within a page?

  • looks like bounty material to me :) – Alex Weber Apr 24 '11 at 14:14
  • I would recommend either putting these node add forms on different pages or creating a single form the the forms api and having the submit function save this data to multiple content types. I don't think what you're looking for is supported out of the box. – MikeNGarrett Apr 27 '11 at 15:51
  • Ah damn! Stupid me. I added a bounty by mistake. How do I take this back? – Tivie May 31 '11 at 21:48
1

I doubt that panels can handle it.

I would try creating a custom page with hook_menu and outputting all the forms on it via a page callback like $output = drupal_get_form('foo_node_form'); $output .= drupal_get_form('bar_node_form'); return $output;

1

$created = true in the ctools_context_create_node_edit_form function in the node_edit_form.inc context plugin seems to be the one thing keeping us from adding multiple content profile node forms to a user edit form.

we easily added the first node edit form by passing a context, but the second one wasn't available on the layout page. if we comment out $created= TRUE we can pass in multiple node edit form contexts.

it seems that this value is being set as part of a performance thing? we are going to copy the whole file, rename it, create a custom module, and drop it in.

1

Disclaimer: I haven't tested the following solutions myself.

Assuming you don't mind adding blocks to panels you can try the following solutions. Just make sure you allow blocks and regions in your panel.

I personally had problems with nested form tags using mini-panels (which should have worked in theory) so this (i.e. blocks) is the only solution I have outside of creating custom Ctools plug-ins.

(1) Try the Advanced Form Block module to create a custom block. It does nifty things like AJAX submits, multiple blocks and field selection.

(2) Write a module to create a custom blocks using hook_block_info and hook_block_view. In this example, a $form_state is passed along to drupal_build_form so you'll make sure language etc is passed in and that your includes (node.pages) is refreshed each time with AJAX loads.

function custom_example_block_info() {

    $blocks['example_node_form'] = array(
       'info' => t('What an example'), 
    );
    return $blocks; 

}

function custom_example_block_view($delta = ''){

    $block = array();

    switch ($delta) {
        case 'example_node_form':
            global $user;
            //Note: 'type' is your node content type and 'language' must be included
            $node = (object) array('uid' => $user->uid, 'name' => (isset($user->name) ? $user->name : ''), 'type' => 'example', 'language' => LANGUAGE_NONE);

            $form_state['build_info']['args'] = array($node);

            form_load_include($form_state, 'inc', 'node', 'node.pages');
            $block['content'] = drupal_build_form('example_node_form', $form_state);

            break;
    }
return $block; 

}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.