I am using Drupal 6 and I got a node form for a content type. I want to alter the other content type node form inside the first one; is that possible?


You can also use Flexifield to get 2 content types on the same form.

Like docs says:

You define a field combination by creating a node type and adding fields to it. On a different node type, you can add a flexifield, and then on its configuration form, specify which node types to use as items within the field.


You may implement hook_form_alter to add some custom fields (Take a look at FAPI) that should represent your second type fields, and treat them in hook_nodeapi with $op presave, (as mentioned by dobeerman).

To save the fields you previously set in your form as new or even and existing node, you may create/load a node object and save them with node_save.


If you want to add values from 1st form to 2nd form you can use hook_nodeapi() to altering 2nd content types node.

function mymodule_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL){
    case 'presave':
      if($node->type == MY_NODE_TYPE){
        // $other_node = node_load($other_nid);
        // or
        // $other_node = new stdClass();
        // $other_node->title = ...
        // ...
        // some code to altering other node
        // $other_node = node_submit($other_node);
        // node_save($other_node);

you can take a look at this module http://drupal.org/project/formblock

Some details from the module's project page:

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

Or just use drush en formblock -y

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.