Hi,

I've discussed this issue on IRC, but haven't found any useable solutions, so I hope anyone here can assist me... :)
I have a custom node type (CCK) with several fields defined. What I want to do is to have a block on my site that shows some of the fields and let anonymous users create that node, but not see it. So.. basically... I want to display the "create node type" page (in a simple, stripped form) in a block an let it function as the "contact form" in Drupal.

My problem is now to find a snippet/solution on how to display some of the CCK fields for the user in a block. When a user has entered all the stuff he/she wants and press submit, the info is stored in the node/CCK fields, but the user is directly forwarded to a "thank you for your submission" node/page.

I've found the following article on 2bits, but it only gives me errors and I don't know how to define my fields...
http://2bits.com/articles/creating-nodes-using-mini-forms-anywhere.html

Comments

cayenne’s picture

If it's just a submission, consider the webforms module. It will do what you want, if it's all text.

:)

NeoID’s picture

...but can the webform module save to a node/CCK field? I thought the webform module saves stuff in its own way...

NeoID’s picture

Nobody who know how I can do this?

The only thing I need is a simple form with a title, body field and a submit/save button. Upon submission the content of the title and body is sent to a set content type and saved.
After the user has hit submit he/she is just forwarded to another node (node/7) that says thank you....

NeoID’s picture

This is the closest I've come to make the form. This gives me the submit and preview button, but how can I add the CCK fields I want/need?

<?php
 global $user;
 $type = 'issue';
 $node = array('uid' => $user->uid, 'name' => $user->name, 'type' => $type);
 module_load_include('inc', 'node', 'node.pages');

  $form = drupal_get_form($type .'_node_form',  $node);

 print_r($form);
?>
Drupalace-1’s picture

I could swear I've read about a module to allow creation / editing of nodes within a block, though I haven't installed or used such a module yet.

Might be this one: http://drupal.org/project/formblock ... or something like that. Does that look useful?

NeoID’s picture

No, I tried it and it didn't allow me to choose what fields to display or not... it just rendered the whole create content type page in a block :/
I've found a lot of topics regarding this problem, but no one was ever solved...

stephen verdant’s picture

I'm doing something a little similar. Using Form Block module for to move the form into a block, and alter_form to make changes to the form. A lot might hinge on your approach to hiding/displaying, simple solutions could come from css.

I looked at the 2bits article you mentioned, and it's similar to an approach working for me. So what are your errors? Can you narrow the problem down: is it altering the form, or moving it to a block, that is giving the problems? Have you installed the devel module and perhaps Form inspect ?

With Form Block, you just need form_alter and something like this (I haven't tested it well yet, but seems to be working)

function yourtheme_form_alter(&$form, $form_state, $form_id) {
  if (  $form_id == 'share_room_node_form' )   ) {
    // dsm($form);  
      $form['body_field']['teaser_include']['#access'] = FALSE;
      $form['#content_extra_fields']['revision_information']['#access'] = FALSE;
      $form['comment_settings']['#access'] = FALSE;
      $form['menu']['#access'] = FALSE;
      $form['path']['#access'] = false;
      $form['author']['#access'] = false;
      $form['options']['#access'] = false;
      $form['revision_information']['#access'] = false;
etc.

Can you describe

anjjriit’s picture

thanks

anjjriit’s picture

@Drupalace, Thanks alot for your sharing, This module wich i need for create free ads site.
http://ciptareload.com