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
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

MrVee - March 10, 2009 - 12:34

I would like to know too. This module would work perfect if I could track from which node the form was submitted.

#2

nedjo - March 10, 2009 - 15:23

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

Rosamunda - March 10, 2009 - 21:22

Thanks for your reply, and for the code!
hmmm maybe it could be added it somewhere without much coding...

#4

mikey_p - May 12, 2009 - 10:09

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

tauno - May 17, 2009 - 18:16

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.

 
 

Drupal is a registered trademark of Dries Buytaert.