Jump to content

Phone Number Fieldtype


adrian

Recommended Posts

2 hours ago, adrian said:

could you please try the latest version on the dev branch.

I added a Phone field (called user_mobile) to the user template. I have ListerPro so afterwards I added this field to the Lister of users as an additional column. In this column only the unformatted phone numbers show up and area codes are missing. If I enable country code it is also missing. (I do not need country code right now, I did it for testing purposes only.)

Otherwise in Tracy's console echo $page->user_mobile; and  echo $page->user_mobile->hungarianV1; etc... work as expected.

Link to comment
Share on other sites

6 hours ago, szabesz said:

In this column only the unformatted phone numbers show up and area codes are missing.

Thanks for the report - i was missing a formatValue method which is needed by Lister.

Please try the latest version and let me know how that goes for you.

  • Like 1
Link to comment
Share on other sites

2 hours ago, szabesz said:

One more thing, layout of the input boxes. Is there anything I can do to turn it into a one-liner? Something like:

Yep, coming soon - I have to get off the computer for now, but here is what it looks like. I'll try to commit later today.

Do you think we want pixel or percentage widths? Do we want to make sure there is a enough room for all the digits, or do we want to make sure it fits on one line (which could be an issue with pixels if the phone field itself is maybe 33% (or less) of the row). Any thoughts?

Settings:

image.png.a3a9f7a7b1ea5b2616e7660bd855ea14.png

 

Input:

image.png.2e5175c59fb310f71faf63d2bda20418.png

  • Like 1
Link to comment
Share on other sites

5 minutes ago, adrian said:

Do we want to make sure there is a enough room for all the digits

I would vote for this. Users tend not to notice such subtle things like cut-off text in an input box. Looking ugly is better than users having trouble, I think. So I vote for pixels.

Link to comment
Share on other sites

@szabesz and @godmok

Ok, new version supports custom labels and input widths on a per field basis. The subfield labels are now also translatable:

image.thumb.png.6185d7fb746a502ed2d25e53aea77456.png

 

So in this example, the Spanish rendering looks like this:

image.png.9b435560baffc817d0cc81f0723c926f.png

 

Please let me know if you have any issues/suggestions.

Note for @mel47 - there is currently an issue with the multi-language subfield labels in FormBuilder. Waiting on Ryan here: https://processwire.com/talk/topic/18347-subfield-uselanguages-not-getting-re-populated/

  • Like 2
Link to comment
Share on other sites

I quick follow up on the Form Builder issue - I have a posted a solution to that FB thread - hopefully Ryan will implement, but if anyone wants to use it in the meantime, you can make the change I indicated here: 

 

Link to comment
Share on other sites

On 1/26/2018 at 9:03 PM, adrian said:

@godmok, @szabesz and @mel47 - could you please try the latest version on the dev branch. I had to rejig a few things to get this new version to also work with Form Builder.

@mel47 - please read my previous post above regarding the breaking changes in this new version. I'll be making this the master version once I have confirmation from you guys that you aren't seeing any problems. I don't like introducing breaking changes, but in this case it was necessary to allow more flexibility for calling custom outputs via the API.

Thanks!

Almost working good, but some troubles:

  • Page: The input field does not show the label name if none is set:
    phonefield.png.b814e4becca5337a1f57d3c30ac00439.png
  • Field: set checkbox on "Country Code" and "Extension" is lost, have to activate it again.
Link to comment
Share on other sites

On 1/27/2018 at 5:07 PM, adrian said:

Do you think we want pixel or percentage widths? Do we want to make sure there is a enough room for all the digits, or do we want to make sure it fits on one line (which could be an issue with pixels if the phone field itself is maybe 33% (or less) of the row). Any thoughts?

Fields in admin use percent as default width, so I would vote for: checkbox for the default option if to use pixel on input fields, if not set, then use percentage.

You can be quite flexible if there is a check for:

  • %
  • em
  • rem
  • px
  • number only

and use this as the width value. "Number only" will use percentage or pixel width if option is checked.

I am looking at mobile use, too, and pixel are not so fun to use there. ;)

Link to comment
Share on other sites

2 hours ago, godmok said:

Almost working good, but some troubles:

  • Page: The input field does not show the label name if none is set:
    phonefield.png.b814e4becca5337a1f57d3c30ac00439.png
  • Field: set checkbox on "Country Code" and "Extension" is lost, have to activate it again.

Hi @godmok - thanks for the report - regarding the checkboxes not sticking, I am not seeing that issue here. Is your phone field just a regular field, or is it inside a repeater, or is there anything else unusual? As for the labels not appearing unless explicitly set, I will check that shortly.

I'll play around with more options for setting the subfields widths.

 

Link to comment
Share on other sites

4 hours ago, godmok said:

Page: The input field does not show the label name if none is set:

Please try the latest version just committed - this should now be taken care of. I am still not sure about the country/extension checkboxes - they are working fine here. Could you please try the latest version anyway and see if it helps, but also any other info about the field would be helpful.

Link to comment
Share on other sites

4 hours ago, godmok said:

I am looking at mobile use, too, and pixel are not so fun to use there.

Maybe not, but as @szabesz and I discussed, it's also not good to have a  field that is too narrow to accommodate the length of the number that needs to be entered. I think I'd actually prefer the subfields to be on separate lines (wrapped) if the screen is too narrow.

Anyone else have any better suggestions?

  • Like 2
Link to comment
Share on other sites

21 hours ago, adrian said:

Please try the latest version just committed - this should now be taken care of. I am still not sure about the country/extension checkboxes - they are working fine here. Could you please try the latest version anyway and see if it helps, but also any other info about the field would be helpful.

Now it is working. This was a great update!

The field is a simple field in a user profile template.

  • Like 1
Link to comment
Share on other sites

3 hours ago, godmok said:

Now it is working. This was a great update!

Glad to hear.

While I am introducing breaking changes, I thought it was time to tweak the output format syntax a little. I have committed a new version to the dev branch.

It is now recommended to put your spaces and dashes outside the curly braces, eg:

{+[phoneCountry]} {([phoneAreaCode,1,1])} {[phoneNumber,0,4]}-{[phoneNumber,4,4]} {x[phoneExtension]}

Compare this to the old version:

{+[phoneCountry] }{([phoneAreaCode,1,1]) }{[phoneNumber,0,4]-}{[phoneNumber,4,4]}{ x[phoneExtension]}

I think the new way is cleaner, because the space, dash, etc between number components are not actually part of the component itself.

Note that for the country "+" or extension "x" you still want those inside the { } component delimiters because they actually belong to that component of the number.

Does that make sense and seem like a logical improvement to you?

 

  • Like 3
Link to comment
Share on other sites

@godmok and everyone!

Ok, hopefully this is the last update before pushing dev to master.

This new version moves the "example numbers" into the Output Format Options syntax so that you can specify different numbers for each format which is important so you can tell from the dropdown whether the numbers are being formatted correctly or not.

The syntax is: name | format | example numbers

For example:

northAmericaStandard | {+[phoneCountry]} {([phoneAreaCode])} {[phoneNumber,0,3]}-{[phoneNumber,3,4]} {x[phoneExtension]} | 1,221,5673456,123

australiaWithCountryAreaCodeNoLeadingZero | {+[phoneCountry]} {([phoneAreaCode,1,1])} {[phoneNumber,0,4]} {[phoneNumber,4,4]} {x[phoneExtension]} | 61,07,45673456,123

Note that the example numbers are comma separated for each component of the number. You can see the output in the dropdown in this screenshot. See how I have a leading zero/two digit area code and 8 digit number for the Australian examples vs 3 digit area code and 7 digit number for North America.

image.thumb.png.218c16b9b87bb13b9f851be0e61f0336.png

 

Remember that this new 2.x version needs a different syntax for the format options, so if you are upgrading from 1.x, you will need to adjust, or empty the settings to have the new defaults populate automatically.

This is OT, but I think it's a good excuse to advertise @netcarver's awesome ModuleReleaseNotes which shows what's changed when you go to upgrade a module (using Ryan's PW Upgrade module). Most importantly it highlights when a module is tagged as having breaking changes, which this new v2 of FieldtypePhone has.

I hate implement breaking changes, but sometimes you just have to :)

I'll give it another couple of days for the dust to settle (and here back from you guys) before pushing to Master.

 

  • Like 2
Link to comment
Share on other sites

6 hours ago, Juergen said:

Hello Adrian,

thanks for the great update! In my case it seems that the field description and notes will not be outputted in the backend. Can someone confirm this behavior?

Best regards

Thanks @Juergen - sorry about the description/notes issue - it's fixed in the latest version.

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

Just added a new option: "Hide Input Labels" that results in a more compact input. 

Not sure I would recommend this if you are also displaying the country and extension inputs, but if it's just area code and number, then I think it works well and would make sense to the user.

image.png.0aacc7d8c7e43763172cfe4d1c53409b.png

  • Like 1
Link to comment
Share on other sites

Hello Adrian,

could you please check the following:

After updating the module all my labels of the different input fields (area code and so on) with the translations are gone. I had to enter it once more. It seems that updating the module deletes all entered label values.

Thanks

PS: The only message I got from Tracy was the following:

PHP Notice: Undefined offset: 3 in .../site/modules/FieldtypePhone/FieldtypePhone.module:322

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...