The following warnings occurred:
Warning [2] Undefined array key "avatartype" - Line: 783 - File: global.php PHP 8.1.27 (Linux)
File Line Function
/global.php 783 errorHandler->error
/printthread.php 16 require_once
Warning [2] Undefined array key "avatartype" - Line: 783 - File: global.php PHP 8.1.27 (Linux)
File Line Function
/global.php 783 errorHandler->error
/printthread.php 16 require_once
Warning [2] Undefined variable $newpmmsg - Line: 40 - File: global.php(841) : eval()'d code PHP 8.1.27 (Linux)
File Line Function
/global.php(841) : eval()'d code 40 errorHandler->error
/global.php 841 eval
/printthread.php 16 require_once
Warning [2] Undefined array key "style" - Line: 909 - File: global.php PHP 8.1.27 (Linux)
File Line Function
/global.php 909 errorHandler->error
/printthread.php 16 require_once
Warning [2] Undefined property: MyLanguage::$lang_select_default - Line: 5024 - File: inc/functions.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions.php 5024 errorHandler->error
/global.php 909 build_theme_select
/printthread.php 16 require_once
Warning [2] Undefined array key "additionalgroups" - Line: 7162 - File: inc/functions.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions.php 7162 errorHandler->error
/inc/functions.php 5044 is_member
/global.php 909 build_theme_select
/printthread.php 16 require_once
Warning [2] Undefined array key 1 - Line: 1415 - File: inc/functions.php PHP 8.1.27 (Linux)
File Line Function
/inc/functions.php 1415 errorHandler->error
/inc/functions.php 1370 fetch_forum_permissions
/printthread.php 76 forum_permissions
Warning [2] Undefined array key "showimages" - Line: 160 - File: printthread.php PHP 8.1.27 (Linux)
File Line Function
/printthread.php 160 errorHandler->error
Warning [2] Undefined array key "showvideos" - Line: 165 - File: printthread.php PHP 8.1.27 (Linux)
File Line Function
/printthread.php 165 errorHandler->error
Warning [2] Undefined array key "showimages" - Line: 160 - File: printthread.php PHP 8.1.27 (Linux)
File Line Function
/printthread.php 160 errorHandler->error
Warning [2] Undefined array key "showvideos" - Line: 165 - File: printthread.php PHP 8.1.27 (Linux)
File Line Function
/printthread.php 165 errorHandler->error



Form Tools
Allowing users to update an existing form record - Printable Version

+- Form Tools (https://forums.formtools.org)
+-- Forum: Form Tools (https://forums.formtools.org/forumdisplay.php?fid=1)
+--- Forum: API (https://forums.formtools.org/forumdisplay.php?fid=17)
+--- Thread: Allowing users to update an existing form record (/showthread.php?tid=1731)



Allowing users to update an existing form record - arunrajv - Oct 31st, 2011

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


RE: Allowing users to update an existing form record - arunrajv - Oct 31st, 2011

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;