I've converted everything over to hook_nodeapi() and hook_form_alter() to allow any content type to utilize webforms. I've done some initial tests and this code seems to work nicely. I've not tested it with the form_builder yet, but I wanted to get this up for review.

Eclipse

Comments

eclipsegc’s picture

StatusFileSize
new9.71 KB

A little cleaner of a diff, plus we've hard-coded webforms to always work, and implemented hook_node_op() functions per Drupe 7 standards. I've passed my own variables here as we're not 100% sure what's going to happen to D7. This is especially true with webform_node_view().

I've tested on CCK content types and it works great! Still have yet to test the form_builder functionality.

Let me know if it needs more tweaks.

Eclipse

eclipsegc’s picture

it's worth mentioning that non-webform-type nodes do not show up in 'admin/content/webform'. I kind of see this as scope creep for the patch, but let me know if you feel differently, and I'll come up with a patch that helps this along as well.

Eclipse

joachim’s picture

What about taking this one step further, and making a webform an abstract thing that doesn't have to be tied to a node?
Then other modules could invite users to create forms and use them in different ways without having to create a node and block access to it.

quicksketch’s picture

joachim, that's the Form Builder project you're describing (basically), which allows you to build arbitrary forms without any regard to how the form will be used. Webforms are tied to a lot of things however: e-mail submissions, CSV and Excel exports, data storage, statistics, editing, etc. I will not suffer Webform the abstraction "disease" of Drupal and attempt to abstract it further into basically an alternative to CCK or Fields in core.

rmjackson’s picture

Hello,

I have applied this patch and find that it works wonderfully.

Upon testing I have encountered a few issues:

1. After a webform enabled node has been submitted and is functioning nicely, a user may want to make changes. When I tested this, I received an error when I submitted the change, hitting save.

The error read that there is a call to an unknown function on line 622 on webform.module. That call is to webform_insert. It should be webform_nodeapi, based on the changes that the patch affects.

I changed the line to webform_nodeapi(&$node, $op, $a3=NULL, $a4=NULL);

This caused the call to unknown function to go away.

2. Under the same conditions, editing an existing webform enabled content type, I find my webform needs to be rebuilt. The data is still available, but the form drops out. When I resubmit the fields, the old data reappears.

Being that I'm going into production on Monday, I'm going to disallow editting of webform enabled content type by all roles. However, my client is eventually going to want this changed. Any feedback would be lovely.

Sincerely,

The Canadian Drupal Guy
Robbie Jackson

drewpalmajor’s picture

EclipseGc,

Thank you for your time and direction on this. Currently with this patch, you create your content THEN you can create your form that will be attached to that specific piece of content.

Is there any way to create a form, and have those same fields applied to a content type? When content is created, the drafted form will attach and reference to that content instance (as opposed to having to create form fields every time)? Please advise.

drewpalmajor’s picture

Please advise... anyone? What I'm speaking about is;

- Making a specific webform.
- Making a content type, and attaching the webform to the content type.
- Create content instances, and the same webform will be attached.
- The webform data collected is in reference to that specific content instance.
- Stats on each content instance webform can be manipulated with views (allowing sorting and comparisons)

I'm not sure if I'm properly relaying what is on my mind, so I have attached a visual representation. Please take a look, anybody.

Thanks.

drewpalmajor’s picture

???

joachim’s picture

@7: what you're asking for is different to this issue's topic.
Basically, what you want is a CCK field that produces a particular webform.
Which is kind of what I was after in #3.
But you may have some success using a nodereference that points to the webform node you want.

drewpalmajor’s picture

Joachim,

My apologies. Maybe I should have started a fresh issue? Does using a node reference allow for a data relationship between the webform & and the piece of content it is attached to? Thanks for the heads up.

eclipsegc’s picture

drew,

quicksketch and I have actually discussed that before (attaching a pre-existing webform to a node/type). I don't think you're going to see it happen in this version.

Sorry :-(

Eclipse

drewpalmajor’s picture

EclipseGc,

Thanks for the heads up. I will try to figure out a work around. Wish a novice luck. =0)

adraskoy’s picture

Hmmm - I hope this is not off topic. I'm trying to determine if this thread is addressing the issue I'm having with webform-- please advise.

I have on my site a CCK-based content type, and also a webform. The webform needs to include information from all existing nodes of that particular content type. As far as I can see, my only option is to manually copy the information. WIll the patches discussed here address this issue? Sorry if not. I'm not certain where else to ask this question.

drewpalmajor’s picture

#13

Your inquiry won't get answered by here. I would try the General Forums (though even then you might not get a response). The issues are for more specific items. Webform and CCK serve completely different uses and I don't think they can reference each other. Take care.

cybermache’s picture

I just applied this patch and just having this ability is awesome. I hope that is gets included in the next release. I think I may have found one problem though. I am now unable to deselect Anonymous users for the Submissions Access fieldset, "Roles that can submit this webform". I could do it before but not now.

Other wise everything else so far works well. I have not yet tested all input fields but so far so good.

cybermache’s picture

Actually no changes are capable at all with the Submissions Access area. I find I cannot take off the two default nor select any other of my roles. I am not receiving any errors that I can see either.

cybermache’s picture

Also, clicking 'save configuration' to change anything on the form settings page removes the form components and none of the changes made on that page are saved. It seems the submissions are still in the database but the component that displayed is now gone.

cybermache’s picture

One more thing I found is that when creating a basic webform using content type 'webform' 'title' and 'body' are not available. They simply aren't there and have disappeared from previous webforms as well. I will double check my patch and see if it was applied correctly.

cybermache’s picture

Status: Needs review » Needs work
quicksketch’s picture

Status: Needs work » Fixed
StatusFileSize
new11.23 KB

I extended EclipseGc's patch a bit to address remaining concerns:

- A default type "webform" is created on install, an update function converts the existing webform type to be owned by node module (fixing the title and body issue).
- I added a missing hook_node_type() so that a node type can be renamed and still keep the Webform functionality.

I've committed these changes. Thanks a lot to EclipseGc for your work!

eclipsegc’s picture

WOOT!

pvasener’s picture

Excellent! Thanks for integrating this feature, it's a GREAT improvement for webform.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Doud’s picture

Version: » 6.x-3.x-dev

Excellent, thanks a lot!

There is one last thing that could be done to improve this patch.
Currently the node type settings are stored in one variable "webform_node_types".
It makes it hard to export content type settings with modules such as strongarm and features, as there only 1 variable to store all the webform node type settings.

The best would be to create one variable per content type, ie: [content type name]_webform_settings

eclipsegc’s picture

That sounds great, why don't you open a new issue for it though, this issue has been closed for over 2 years.

Eclipse