5

My goal is to display a form in a page made with panels. The form will be between content panes.

The single page (made with page manager & panels) will be like below:

  1. Content Pane
  2. Form
  3. Content Pane

How can I achieve that, and display the form in a page made with panels ?

Update 2-4-2014: I found this article and created the following block that doesn't work (I am getting an error when trying to add that to panels). can sombody help make this thing work?

<?php 
function my_answer_form_block_info() {
    $blocks = array();
     $blocks['my_answer_form'] = array(
            'info' => t('My-Answer-Form'),
            'cache' => DRUPAL_CACHE_GLOBAL,
    );

    return $blocks;
}

function my_answer_form_block_view($delta = '') {
    $block = array();
    switch($delta) {
            case 'my_answer_form':
                    $block['subject'] = t('My Answer Form');
                    $block['content'] = drupal_get_form('answer_node_form');
            break;
    }
     return $block;
}
  ?>

Note: Form ID is: "answer_node_form"

I am using the Answers Module. The form I want to put on the panel page is the Answer Form, that was created by the Answers Module. Is that a node form or a custom form?

  • is it node form or your custom form created using module? – Ali Nouman Feb 1 '14 at 15:43
  • Hey, I updated my question. I am using the Answers Module. The form I want to put on the panel page is the Answer Form, that was created by the Answers Module. Is that a node form or a custom form? – EB84 Feb 4 '14 at 9:28
  • I think you might find your "My Answer Form" block listed under Miscellaneous in Panels' add content dialog? – artfulrobot Jun 6 '14 at 11:36
1

If it is node form you could use Form Block. It will create form in block and you could add that in content panes.

Enables the presentation of user registration, site wide contact, or node creation forms in blocks. This is particularly useful for including forms on panels.

  • I am using Drupal 7, and there is no stable version of the form block module for Drupal 7. I tried to use the DEV version with panels, but then I have errors and some bugs (I can't add more panels after adding the form block). I will be happy to get help here , or any other suggestions? – EB84 Feb 1 '14 at 22:34
0

If you want a simple form for user submissions I would recommend using webform. With this module you can expose it as a block and add it to a panel page.

If it is a custom form, for generation nodes or entities for example, I would recommend writing your own form with the Drupal Form API and exposing it as a block to put it on your panel page.

A good starting point for writing your own modules is the Drupal examples module. This gives you really good insight into how forms need to be structured and also how to create your own blocks.

I hope this helps you.

  • Thank you for your answer. In this specific case my goal is to put the Answer Form of the Answers Module on my panel page. Do you have more insights for this specific case? – EB84 Feb 3 '14 at 20:39

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.