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 8513479
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T04:34:55+00:00 2026-06-11T04:34:55+00:00

I am creating a custom module that allows for users to create blog posts

  • 0

I am creating a custom module that allows for users to create blog posts that will be private and related to a project. So I created a new content_type called “tasker_blog” that just has a title and body. The user goes to view their projects and clicks a link which takes them to ‘tasker_project/%/blog’ % being the id of the project. I have the form being displayed correctly but when I submit the form I have two problems,
1) the title is lost on submit
2) getting this error: EntityMalformedException: Missing bundle property on entity of type node. in entity_extract_ids().

Here is the code I have written (some non-relevant parts taken out).

function tasker_project_menu() {
    $items = array();

    $items['tasker_project/%/blog'] = array(
        'title' => 'Private Blog Post',
        'page callback' => 'drupal_get_form',
        'page arguments' => array('tasker_project_blog_form',1),
        'access arguments' => array('view tasker projects'),
        'type' => MENU_CALLBACK,
    );

    return $items;
}

function tasker_project_blog_form($form, &$form_state) {
    drupal_add_css(drupal_get_path('module', 'tasker_project') . '/tasker_project.css'); 
    global $user;
    module_load_include('inc', 'node', 'node.pages');
    $node = (object) array(
        'uid' => $user->uid,
        'name' => (isset($user->name) ? $user->name : ''),
        'type' => 'tasker_blog',
        'language' => 'und',
    );
    node_object_prepare($node);

    $form = drupal_get_form('tasker_blog_node_form',$node);
    $form['hidden_project_id'] = array(
        '#type' => 'hidden',
        '#value' => arg(1),
    );

    return $form;
}

If I submit with nothing else added I get the error I mentioned above. If I add this (using Kint to display variables):

function tasker_project_node_validate($node, $form, &$form_state) {
    s($_REQUEST);
    s($form_state['values']);
    die();
}

$_REQUEST array output:

array (9) (
    'title' => string (4) "test"
    'body' => array (1) (
        'und' => array (1) (
             array (2) (
                'format' => string (13) "filtered_html"
                'value' => string (13) "<p>test</p>
"
            )
        )
    )
    'changed' => string (0) ""
    'form_build_id' => string (48) "form-eKWwyFlBOzi4LsajaAiEZBG7J0uOSI1UDVIhiDomeJE"
    'form_token' => string (43) "N421-IiWecixBJGbxTHGcJAIrd6ZutzAW0LAtVSsrJ4"
    'form_id' => string (24) "tasker_project_blog_form"
    'hidden_project_id' => string (2) "10"
    'additional_settings__active_tab' => string (0) ""
    'op' => string (4) "Save"
)

$form_state[‘values’] array output:

array (27) (
    'nid' => NULL
    'vid' => NULL
    'uid' => string (1) "5"
    'created' => integer 1347038959
    'type' => string (11) "tasker_blog"
    'language' => string (3) "und"
    'changed' => string (0) ""
    'title' => string (0) ""
    'additional_settings__active_tab' => string (0) ""
    'revision' => bool FALSE
    'log' => string (0) ""
    'name' => string (10) "ndenlinger"
    'date' => string (0) ""
    'status' => integer 0
    'promote' => integer 0
    'sticky' => integer 0
    'submit' => string (4) "Save"
    'preview' => string (7) "Preview"
    'body' => array (1) (
        'und' => array (1) (
             array (3) (
                'summary' => string (0) ""
                'format' => string (13) "filtered_html"
                'value' => string (13) "<p>test</p>
"
            )
        )
    )
    //...MORE HERE REMOVED SINCE NOT RELEVANT
)

So I’m not sure if the two problems are related or not. Once the node is saved I am going to add a row to a custom table that store the nid and the project_id.

  • 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-06-11T04:34:57+00:00Added an answer on June 11, 2026 at 4:34 am

    Found the solution if anyone else ever has this issue:

        drupal_add_css(drupal_get_path('module', 'tasker_project') . '/tasker_project.css'); 
        global $user;
        module_load_include('inc', 'node', 'node.pages');
        $node = (object) array(
            'uid' => $user->uid,
            'name' => (isset($user->name) ? $user->name : ''),
            'type' => 'tasker_blog',
            'language' => 'und',
        );
        node_object_prepare($node);
        $form_state['build_info']['args'] = array($node);
    
        $form = drupal_retrieve_form('tasker_blog_node_form', $form_state);
        drupal_prepare_form('tasker_blog_node_form', $form, $form_state);
        $form['hidden_project_id'] = array(
            '#type' => 'hidden',
            '#value' => arg(1),
        );
    

    I used drupal_retrieve_form and drupal_prepare_form and everything seems to work correctly now. Not sure why drupal_build_form or drupal_get_form don’t work correctly.

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

Sidebar

Related Questions

I am new to magento and i am Creating Custom module for File upload
I have a module that is used by creating a custom class loader. The
I'm creating a custom module that has uses the form API and sends an
I created a custom block (by creating a module and doing a layout update
I'm creating a custom module for a specific function in the admin of Magento.
In Magento I'm creating a custom module and would love to be able to
We want to use Orchard for a website. We are creating a custom module/widget
I'm creating a custom Drupal 7 module and within my module I'm creating a
I am creating a custom Survey package which has questions module , answers module
I'm creating a custom module and I need to be able to read the

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.