DOCUMENTATION

  • Developer
Search »

Submission Pre-Parser

Combining Fields

Note: Phone number fields are now predefined field types in Form Tools 2.1.0. You can read about them here! But this example illustrates how you could emulate it manually.

Combining Form Fields

A common way to take phone numbers in forms is by separating it into components, like so:

()

The problem with this is that in the Form Tools UI, each field is displayed separately on separate lines. Functionally this is still sound, but it's a bit ugly and hard to read. Instead, you can create a pre-parser rule to combine them.

  1. First, in your Edit Form ยป Database tab, create a new field called just "Phone" or something simple, and enter "phone" as the form field name.
  2. Next, add this new field to one of your Views. This is important! Otherwise your new field won't show up anywhere in the Form Tools UI.
  3. Go to the Submission Pre-parser module and add a new rule with the following PHP:

And you're done! The three phone form fields (here assumed to have the names "phone_1", "phone_2" and "phone_3") are now combined to make a single field, stored in the "phone" database field, looking like this:

For the final touches, you'll probably want to either remove the separate phone fields from your View or from the database altogether.