1

I would like to create a webform which accepts input from two parties. First party fills out part of a form and share a link with second party to proceed with the rest.

I have found 'save draft' feature useful for this service but only loads pre saved info for the same person. Is there anyway I can share a link (based on sid) so that whenever the URL has a SID parameter, it loads pre saved info?

Thanks

2
  • you could save party 1 info on a custom DB table and then load the info when party 2 fills out their form.
    – No Sssweat
    May 6, 2016 at 3:26
  • @NoSssweat Thanks. I was thinking of creating a content type for the first party so it saves data on the same Drupal database. Can you please explain more about filling info for party 2? Not a fan of URLs with really long parameters. Is there a way to just call SID as parameter and load data? May 6, 2016 at 3:46

1 Answer 1

0

I was thinking of creating a custom module that creates form 1 which saves the info in DB tables with a unique value of SID.

Form 2, which has url of /example/% the variable % being the sid.

loads info from db using the url parameter.

$sid = request_path(); // gets the current page url. ex: example/sid
$sid = str_ireplace('example/','', $sid); // removes the example/ from our variable, so we are left with sid

Now that you have the sid inside $sid, you can query the db to grab your fields.

EX:

$field1 = db_query("SELECT field1 from {table_name} WHERE sid = :sid LIMIT 1", array(":sid" => $sid))->fetchField(); 

PS: In case you are wondering why the mysql query looks the way it does, see Writing secure code and How do I get only one result using db_query()

14
  • With custom module, are you saving data in a new custom table? And isn't SID always unique? Sorry I'm pretty new to Drupal. Should I insert the code you provided inside form_alter for Form 2? is taxonomy_term_data is same as the table name? May 6, 2016 at 4:35
  • @user2574948 yes table_name, sorry, I copy pasted from another of my answers and modified, forgot to change that. Yes should go inside form_alter if you're altering a form.
    – No Sssweat
    May 6, 2016 at 4:47
  • @user2574948 I highly recommend you install the examples module, which has good examples for creating forms. Then take a look at the source code to see how the example works.
    – No Sssweat
    May 6, 2016 at 4:49
  • I have installed examples module but can't see any links to tutorials. How can I use this module? May 6, 2016 at 6:58
  • @user2574948 you need to enable "Form Examples" then in your "Navigation Block" you will see links to each example d08of.ply.st. Then you just have to look at the source code in /sites/all/modules/examples/form_examples to see how it works.
    – No Sssweat
    May 6, 2016 at 7:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.