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
Submission Pre-Parser
#1
Hi,
In form tools I am using the Submission Pre-Parser module with an API form.
It states in the description if you need to split a single form field into multiple fields, this can be done.

Can anyone give me an example of how this is done?

IE, I am adding 1278|Toy 2 as a value in a drop down. I would like to separate via the | and store the id "1278" in an id field and "Toy 2" in a toy field.

Thank you in advance,
Bill
Reply
#2
Hi Bill,

Here is an example from our documentation on how to use the submission pre-parser: http://modules.formtools.org/submission_...ds_example

You can add your rules into the pre-parser and use the explode function: http://php.net/manual/en/function.explode.php

Cheers,

Joe
Reply
#3
Hi,
Thanks for the reply.
I have seen the example but what I want to do is the exact opposite.

If my value for frm_toys is 1278|Toy
How would I split that based on the separator and post 1278 to id and Toy to Name
Using the pre-parser?
Reply
#4
You'll need to tinker around with this, but the code should be something like:

if ((isset($_POST["frm_toys"]) && !empty($_POST["frm_toys"])) = explode("|", $frm_toys);
$_POST["ID"] = $drop_down_field[0]; // ID field needs to be defined in Form Tools already
$_POST["name"] = $drop_down_field[1]; // name field needs to be defined in Form Tools already

Cheers,

Joe
Reply
#5
That should give me the start I needed.
Thank you very much!
Reply
#6
if ((isset($_POST["frm_toys"]) && !empty($_POST["frm_toys"])) = explode("|", $frm_toys);
$_POST["ID"] = $frm_toys[0];
$_POST["name"] = $frm_toys[1];

$drop_down_field was just an example. Replaced it with the variable you were using.

Cheers,

Joe
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)