FORUMS


The Form Tools forums are no longer active, but the old posts have been archived here. Please see the Help page on how to get help / report issues.

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Allowing users to update an existing form record
#1
Hello,

I am a newcomer to formtools wondering about how to implement the following scenario.

The users create the forms through an initial registration - this is not a problem. What I want to do is to allow them to use the same user interface to update their data. They will login through an email ID /password combination, the form fields will be filled with the existing data, and they proceed to update the data just as they did while creating it.

I have taken a look at Submission Accounts module, but it seems to present it's own UI (which I believe can be customized?). But I would like to use the same custom UI with which the form was created.

I have also looked at ft_update_submission(.), but it seems to expect the $infohash parameter to come from the update submissions page in the admin panel (please correct me if I'm wrong!).

Here is the current solution that I have in mind:

- The user enters the email ID and password.
- I use ft_search_submissions to validate the login and retrieve records.
- I fill the form fields with the retrieved values.
- Instead of calling ft_api_process_form(.), I call my own function, myft_update_form($form_id, $submission_id, $data) to update the table. I of course have to name the DB columns etc. to sensible values using smart fill for this to work and deal with the DB directly.

My question: is there a cleaner way to do what I am trying to achieve through the API? The problem with bypassing the API entirely is that I have to manually do all the bookkeeping (such as modification date) that the API takes care of.

Thanks,
Arun
Reply
#2
An update: I have hit upon what's hopefully a minor hack that involved modifying the API a little.

The modification is to pass the $submission_id while calling ft_api_init_form_page(.) the FIRST time, and creating a blank submission only if $submission_id is not set. If it is, I use the $submission_id directly. Seems to work so far (cross fingers!).

In ft_api_init_form_page(.)
Code:
function ft_api_init_form_page($form_id = "", $mode = "live", $namespace = "form_tools_form", $submission_id = false)
{
       // ...
       case "live":
         if (empty($form_id))
           return $_SESSION[$namespace];

        // create a blank submission only if user didn't pass the submission id, otherwise use the user's submission id
         if ( ! $submission_id )
             $submission_id = ft_api_create_blank_submission($form_id);
             
         $_SESSION[$namespace]["form_tools_form_id"]       = $form_id;
         $_SESSION[$namespace]["form_tools_submission_id"] = $submission_id;
         break;
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)