From which link the user submitted the form?
Rosamunda - March 1, 2009 - 03:44
| Project: | Form Block |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Jump to:
Description
Hi!
If I would like to use this module as a "give us your feedback", is there a way to know from which page people have actually submitted the form?
Thanks!!
Rosamunda

#1
I would like to know too. This module would work perfect if I could track from which node the form was submitted.
#2
I can see where this would be useful. But the question would be where to put this functionality? Save the information along with the form submission? If so, save it where?
At any time, you can determine the current location in PHP with:
<?php$location = $_GET['q'];
?>
But I don't think adding this to forms and handling saving would fit well in formblock. It could be done as a separate module I guess.
#3
Thanks for your reply, and for the code!
hmmm maybe it could be added it somewhere without much coding...
#4
I'm not sure if there is a good way to add this option to the module. Perhaps you could try a combination of the Computer Field module (http://drupal.org/project/computed_field) and CCK field permissions to get a field set with custom PHP and hide it from the user. I'm not sure if that will work, but it may be worth looking into.
#5
Using a Computed Field seems like a good solution. Here is my code to get the node type and page title from the node the form was submitted from:
<?php
if (arg(0) == 'node' && is_numeric(arg(1)) && (!arg(2))) {
$nid = arg(1);
$src_node = node_load(array('nid' => $nid));
$title = $src_node->type ." - ". $src_node->title;
} else {
$title = "Unknown";
}
$node_field[0]['value'] = $title;
?>
You can modify the code to get any field from the source node you want. Don't mess with $node in your computed field, it breaks the submission form.