By limehouse on
Hi
I want to link to a webform from a custom content type, so that the form displays (eg) the content type 'title' /id, and saves this along with the other form webform data.
Is there a simple way to do this? No PHP knowledge my end so would need to be quite simple!
Thanks for any help.
Comments
I don't understand what you
I don't understand what you mean by 'linking a webform to a content type'. A webform is a content type itself, so you can't give it another content type. Also, you seem to mix up 'content type' and 'node ID'.
Anyway, when you link to a webform node, you can pass variables to it. If you can clarify what you're trying to do, I guess we can help you do it.
Hi
Thanks for your response.
I mean to say that I want to link to a webform from an instance of a custom content type eg a node. So yes I want to be able to pass variables from the node to the webform (e.g, the node title/ID).
I think this might involve using the %get[key] but I have no idea how this works. And how would I link to the webform from the node (would I include some sort of node reference field using views?)
Thanks for any help.
OK, I think I get it. You
OK, I think I get it.
You are right about the %get[key] method. Basically, it means that you pass variables through the url. For instance: on www.example.com/node/10 there is a link to your webform. When your webform's url is www.example.com/node/24, you could pass the nid variable to it by linking to www.example.com/node/24?id=10. In your webform you can take the variable from the url and set is as default value for a field using
%get[id].Now the question remains: how do you generate the link in your node? Of course you can just enter it manually:
<a href="www.example.com/node/24?id=10">webform</a>. Another option is to use a computed field which automatically creates this link using the node ID.I hope this answers your question.
Hi
Thanks for this. Sorry if I wasn't clear earlier.
Now I understand the principle, I just need to try it and see what I really don't understand!
Here goes...
That's ok, sometimes it
That's ok, sometimes it asking the right question is harder than giving the right answer :-)
Let us know when you run into more problems.
Thanks for the kick start -
Thanks for the kick start - I am heading for much the same sort of result.
I have many events for which I have a single 'sign me up for this event " webform and I need the title of that event
I've used your starter clues as above and now the webform has a default field pre-filled with the referring event node number (success!)
I surmise that the 'calculated' link in any event-node could then be in the form/style of "...example.com/node/24?id=%get(id)" - would that work?
I've searched for while but cannot find how to produce a computed field (ie a computation using keys) in the webform eg: %Get(title of referring-node-number)
Is it something like %Get($title(ID)) ??
Searches for %Get(key) listings don't show up much - and searches for computed fields takes me into CCK...
A guide as to where to look would be useful
thanks
CCK
That's right, computed field is a CCK component. CCK allows you to add your own fields to a content type. A computed field is one of those fields (other examples are number fields, text fields, date fields, email fields with validation etc. etc.) You have to add a computed field to your content type and configure it, so computed field will create the link and store it as part of the node. You will need to install CCK and the computed field module if you want to use this method.
By the way: The "%get(id)" syntax is specific to the webform module; I haven't seen other modules yet that use it.
Instead of creating the link with a computed field, you could also use the contemplate module. This will not store the link as part of the node, but it will create the link when the page is rendered. In the template you should add this to create the link:
Hi marcvangend
Thanks a lot for this. It works well.
Only one issue. The %get value I pass through to the form, is not included in the email webform generates. Even if I check the include in email box. Also (may be same issue) if I have that form field as mandatory I get error message that field has not been completed. So to submit form I have to make field optional.
Any ideas?
Thanks for all your help.
Cheers.
Do you see that %get value
Do you see that %get value appear in your form at all? If not, it is not properly loaded as default value for the field. If you do, it sounds like a bug.
%get value
Very intersting what you are doing can you tell me where do you have to put the %get value.
I made a cck contetn type and a webform i use the contemplate manner.
Thanks,
Peter
elsewhere in this
elsewhere in this thread:
"In your webform you can take the variable from the url and set is as default value for a field using %get[id]."
So basically, you have to do two things: 1) you create a link containing a get value and 2) you pull this value into the 'default value' setting of a webform field.
Node id to tiltle
Thank you for the explanation, it works.
Can you perhaps tell me how i can display the name of the title or some other filed instead off the id of the node in the webform.
I hope this isn't a stupid question.
thnx,
Peter
$node->title
When you create the link, insert the title value instead of the node id.
would become
and for the webform default value you use
%get[title].Drupal 6
Thank you for your quick respons, maybe a little strange but i did not have to change %get[title] to get it working.
Although the title was taken into the webform.
Is there also a way for Drupal 6 to pass a node ID to webform?
thnx,
Peter
Sure, you can pass as many
Sure, you can pass as many values to your webform as you like. For instance:
If the code in my previous comment worked without changing %get[id] to %get[title], I think you overlooked the fact that I also wrote 'title' here in the url: "www.example.com/node/24?title=".
Great
It works.
Thank you very much.
Peter
I'm doing something similar but...
I'm doing something similar but...
I'm getting a value from the URL using %get[item]. From there, I need to set several default values in the form. There are too many to pass all the data through the URL so I planned on using PHP to set the values after a series of if statements based on 'item'. It seems easy but I can't figure it out. Any thoughts?
Can you explain in some more
Can you explain in some more detail what you're trying to do? If you're passing so much values to your webform that they don't fit in a url, there might be a better solution alltogether.
By the way, if you're passing several values to a webform, you need a get variable for every single one of them. For instance: use www.example.com/webform?item1=foo&item2=bar&item3=yadayada to access %get[item1], %get[item2] and %get[item3] in your webform.
A better explanation (hopefully)
Thanks for your reply. I'll do my best to explain better with this example:
On page1, a user selects their favorite sandwich from a dropdown menu.
Page2 is my webform. I would like something like this to happen in the PHP (or somewhere else) with the values then to be set as default values in the form:
First, from the PHP code I use GET to get the 'sandwich' from the URL: www.example.com/orders&sandwich=SandwichSelectionFromPage1
if 'sandwich' = "Ham & Cheese" ($bread=white, condiment1=mayo, condiment2=mustard, meat1=ham, meat2=none, cheese1=swiss, cheese2=none,
ButcherEmail=Porkman@example.com, DairyEmail=Swiss@example.com, CookEmail=Cook1@example.com, etc.)
if 'sandwich' = "Hot Pastrami ($bread=rye, condiment1=kraut, condiment2=mustard, meat1=pastrami, meat2=none, cheese1=swiss, cheese2=none,
ButcherEmail=PastramiMan@example.com, DairyEmail=Swiss@example.com, CookEmail=Cook2@example.com, etc.)
if 'sandwich=...ETC...
All of these fields on the form would need to default to the values from the if statement. Some would be visible to the user and changeable, some would not.
To pass all these variables through the URL would make for a messy, nasty URL that I would prefer the users to not see, especially the email addresses as some of them are hidden from the user in the form.
Does this make more sense? It seems like it should be very simple to "SetDefaultValue[butcheremail]=PastramiMan@example.com" but I can't seem to figure it out.
Thanks for reading!
Thanks Stioc, I understand
Thanks Stioc, I understand you much better now. Unfortunately for you I'm not sure what the best solution would be.
Maybe it's possible to create a content type 'sandwich' which can contain all the variables you will need in the webform. Then you should figure out if you can just pass the id of the sandwich node to the webform (example.com/webform?sandwich=12) and make the webform load all default values from the node. I'm really don't know it this would be easy or difficult.
Maybe webform isn't the best option at all for this job, and you could do it with cck completely... I'd like to have more answers for you but I don't. If you get this to work (or at least get closer to a solution) I'd love to read what you did.
Thanks for the suggestions.
Thanks for the suggestions. I had thought about the node id pass (it would actually work even better since I already have nodes for each) but I was left with the same problem where I couldn't pull out node values as default values in the form.
I'll post here if I come up with some other solution!
By the way, wouldn't
By the way, wouldn't e-commerce solutions like ubercart offer this kind of functionality out-of-the-box? I never used one of these modules, but it might be good to check it out.
%Get[bar] results in "<?php print $node->bar; ?>...
%Get[bar] results in "
print $node->bar;instead of the actual "bar" reference.I can only think this has something to do with saving the link in Full HTML vs PHP Code, etc. in the node field, but I can't yet figure it out. Any help appreciated!
This topic is 5 years old,
This topic is 5 years old, you'd better refer to more recent documentation. If you cannot get it to work, search the webform issue queue or open a new support request there.
title in url is empty?
Hi, there, thanks for all guys's help. I did this on my local machine. If i set id manually, it works well. However, if I set link like this:
print $node->title; ">webform
I have got title in url empty, what do i miss somewhere? please help! thanks in advance!!!!!
Where did you put this code?
Where did you put this code? Depending on the place where you inserted this, the $node variable may not be available.
please help
I don't understand what to do. Please finish thread.
.
Sorry, but you can't just step into a 5-year-old thread and tell us to finish it because you didn't understand something. The information here may not be up-to-date anymore.
If you need support, the least you can do is to describe your own situation, what you did so far, and where it failed. Read http://drupal.org/forum-posting for more tips.