Experimental project
This is a sandbox project, which contains experimental code for developer use only.
A simple phone field module that displays 1 select list and 4 textfields to allow Type [select] (Phone, Fax or Mobile), country code [text], area code [text], number [text] and description [text] to be entered into seperate fields.
Details:
Simple Phone Field is a simple, no thrills field module that can extend Drupal 7 content types to add a phone field, that is split into 5 (since version 1.0-rc2 - see changelog) seperate fields:
- Type: A select list of values Phone, Fax and Mobile [single value - required]
- Country Code: Textfield [max 5 digits - required - must start with '00' - digits only]
- Area Code: Textfield [max 7 digits - required - leading '0' automatically added if missing - digits only]
- Number: Textfield [max 10 digits - required - digits only - can not start with a leading 0]
- Description: Textfield [max 255 characters - optional]
Background:
I wrote this module as I had to somehow capture phone numbers, but have them split into country code / area code and number and save them into seperate columns in the database. All other field modules I tried did not allow for this!
That way all numbers can be entered uniformly and thus presented in a uniform way - especially helpful if you use it to store and manage customer information and possibly need to export it to different applications.
In my case, some users would enter phone numbers with a dash, other with a slash and others again with nothing seperating values making managing them difficult.
Validation:
- Multiple / unlimited values are possible.
- Validates if fields have been entered with numbers
- Validates if 'country code' starts with a double zero '00' - else submission returns an error
- Validates if 'area code' starts with a zero '0' - if not, it adds a 0 before entering in the database - no error given to user
- Validates if the 'number' starts with a zero - no numbers should - submission returns an error
This is my first project and one of my first modules. I will try and actively maintain to the best of my abilities. Any help is always appreciated!
Screenshots:
[updated for rc3]
Node Add Form: http://oi42.tinypic.com/258m04z.jpg
Display: http://oi39.tinypic.com/qz3jur.jpg
Possible plans for the future:
- Possibly create a Module Settings Page
- Better Validation
- Token Support
- Different Formatters
Select list for Tel / Fax / etc ..* DONE
Changelog
version 1.0-rc3
- Fixed formatting for empty description field.
version 1.0-rc2
- Added select list for phone type:phone,fax and mobile.
- Moved description field to end of form.
- Changed translation.
- Removed translations/en.po file as not needed (all items are hardcoded in english using t() anyway).
- Changed themeing of fields and fieldset.
- Various other code changes to handle new fields.version 1.0-rc1
- further validation
- use of form_set_value() to modify area codesversion 0.2
- added translation for english & german
- moved area code formatting into seperate functionversion 0.1.1
- added description field
- changed formatting
- fixed validationversion 0.1:
- initial release
Project information
- Project categories: Site structure
- Created by tecjam on , updated

