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.
- 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.
- 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.
- 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.