Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6775647
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:55:52+00:00 2026-05-26T15:55:52+00:00

I am struggling in my attempts to programmatically display a form to display in

  • 0

I am struggling in my attempts to programmatically display a form to display in my node-page view area. I have the following code in my “simplemodule”.

function simplemodule_newcomer_form($form_state){
    $form   =   array();
    $form['simplemodule_newcomer']['name']  =   array(
        '#type'         =>  'textfield',
        '#title'        =>  t('name'),
        '#description'      =>  t(''),
        '#weight'       =>  -1,
    );
    $form['simplemodule_newcomer']['email'] =   array(
        '#title'        =>  t('email'),
        '#type'         =>  'textfield',
        '#description'      =>  t(''),
        '#weight'       =>  0,
    );
    $form['simplemodule_newcomer']['phone'] =   array(
        '#title'        =>  t('telephone No.'),
        '#type'         =>  'textfield',
        '#description'      =>  t(''),
        '#weight'       =>  0,
    );
    $form['submit_button'] =    array(
        '#type' =>  'submit',
        '#value'    =>  'enter',
    );
    return $form;
}

function simplemodule_newcomer_form_submit($form_id, &$form_state){
    //dealing with submitted data
}

This code works but only from a defined link in my administration menu.

What I want to do is get the form to display and submit on a specific node in view mode. So it creates the effect that there is a form to fill when visiting the node.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T15:55:53+00:00Added an answer on May 26, 2026 at 3:55 pm

    You can implement hook_nodeapi() and attach your form using drupal_get_form():

    function simplemodule_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
    
      if ($node->nid == $the_nid && $op == 'view') {
        $node->content['my_additional_field'] = array(
          '#value' => drupal_get_form('simplemodule_newcomer_form'), 
          '#weight' => 10,
        );
      }
    
    }
    

    You can use the #weight key to specify where in relation to the other content on the page your form will appear. Also you’ll need to clear Drupal’s caches when you implement this hook to make sure it’s picked up.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The problem I have a page with a silverlight object. It attempts to retrieve
Struggling with this one. I have set up a basic email/enquiry form for a
This app attempts to display its 3 views on the main display page, as
I am struggling to understand this simple regular expression. I have the following attempt:
Struggling with styling the mouse over for a button ... I have managed to
Iam struggling with NHibernate and its lazyload. I have a structure which I simplified
been struggling with an issue now for a day or two. I have an
I'm struggling to find the right terminology here, but if you have jQuery object...
I'm struggling to be able to bind a StatusBarItem content element in my view
I'm currently struggling to understand how I should organize/structure a class which I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.