Jump to content
adrian

Phone Number Fieldtype

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.

Share this post


Link to post
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

Share this post


Link to post
Share on other sites
8 hours ago, adrian said:

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

Works! :) Thank you very much!

Share this post


Link to post
Share on other sites

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

phone-input-layout.thumb.png.15c62a16e31fa0689e123280239ee495.png

Share this post


Link to post
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

Share this post


Link to post
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.

Share this post


Link to post
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

Share this post


Link to post
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: 

 

Share this post


Link to post
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.

Share this post


Link to post
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. ;)

Share this post


Link to post
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.

 

Share this post


Link to post
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.

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites
4 hours ago, adrian said:

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

Yes it does. Thanx :)

  • Like 1

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Anyone following this thread have any issues with the dev version before I merge to master?

I'll merge later today if I don't hear anything.

Thanks!

  • Like 3

Share this post


Link to post
Share on other sites

OK, v2 has been merged to master.

Be warned about the breaking changes!

  • Like 3

Share this post


Link to post
Share on other sites

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

  • Like 2

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites
13 minutes ago, adrian said:

if it's just area code and number, then I think it works well and would make sense to the user.

I agree, thanks!

  • Like 1

Share this post


Link to post
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

Share this post


Link to post
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

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By MoritzLost
      This module allows you to integrate hCaptcha bot / spam protection into ProcessWire forms. hCaptcha is a great alternative to Google ReCaptcha, especially if you are in the EU and need to comply with privacy regulations.

      The development of this module is sponsored by schwarzdesign.
      The module is built as an Inputfield, allowing you to integrate it into any ProcessWire form you want. It's primarily intended for frontend forms and can be added to Form Builder forms for automatic spam protection. There's a step-by-step guide for adding the hCaptcha widget to Form Builder forms in the README, as well as instructions for API usage.
      Features
      Inputfield that displays an hCaptcha widget in ProcessWire forms. The inputfield verifies the hCaptcha response upon submission, and adds a field error if it is invalid. All hCaptcha configuration options for the widget (theme, display size etc) can be changed through the inputfield configuration, as well as programmatically. hCaptcha script options can be changed through a hook. Error messages can be translated through ProcessWire's site translations. hCaptcha secret keys and site-keys can be set for each individual inputfield or globally in your config.php. Error codes and failures are logged to help you find configuration errors. Please check the README for setup instructions.
      Links
      Github Repository and documentation InputfieldHCaptcha in the module directory (pending approval) Screenshots (configuration)

      Screenshots (hCaptcha widget)

       
       

       
    • By joshua
      This module is (yet another) way for implementing a cookie management solution.
      Of course there are several other possibilities:
      - https://processwire.com/talk/topic/22920-klaro-cookie-consent-manager/
      - https://github.com/webmanufaktur/CookieManagementBanner
      - https://github.com/johannesdachsel/cookiemonster
      - https://www.oiljs.org/
      - ... and so on ...
      In this module you can configure which kind of cookie categories you want to manage:

      You can also enable the support for respecting the Do-Not-Track (DNT) header to don't annoy users, who already decided for all their browsing experience.
      Currently there are four possible cookie groups:
      - Necessary (always enabled)
      - Statistics
      - Marketing
      - External Media
      All groups can be renamed, so feel free to use other cookie group names. I just haven't found a way to implement a "repeater like" field as configurable module field ...
      When you want to load specific scripts ( like Google Analytics, Google Maps, ...) only after the user's content to this specific category of cookies, just use the following script syntax:
      <script type="text/plain" data-type="text/javascript" data-category="statistics" data-src="/path/to/your/statistic/script.js"></script> <script type="text/plain" data-type="text/javascript" data-category="marketing" data-src="/path/to/your/mareketing/script.js"></script> <script type="text/plain" data-type="text/javascript" data-category="external_media" data-src="/path/to/your/external-media/script.js"></script> <script type="text/plain" data-type="text/javascript" data-category="marketing">console.log("Inline scripts are also working!");</script> The type has to be "optin" to get recognized by PrivacyWire, the data-attributes are giving hints, how the script shall be loaded, if the data-category is within the cookie consents of the user. These scripts are loaded asynchronously after the user made the decision.
      If you want to give the users the possibility to change their consent, you can use the following Textformatter:
      [[privacywire-choose-cookies]] It's planned to add also other Textformatters to opt-out of specific cookie groups or delete the whole consent cookie.
      You can also add a custom link to output the banner again with a link / button with following class:
      <a href="#" class="privacywire-show-options">Show Cookie Options</a> <button class="privacywire-show-options">Show Cookie Options</button> This module is still in development, but we already use it on several production websites.
      You find it here: PrivacyWire Git Repo
      Download as .zip
      I would love to hear your feedback 🙂
      CHANGELOG
      0.1.1 Debugging: fixed error during uninstall 0.1.0 Added new detection of async scripts for W3C Validation 0.0.6 CSS-Debugging for hiding unused buttons, added ProCache support for the JavaScript tag 0.0.5 Multi-language support included completely (also in TextFormatter). Added possibility to async load other assets (e.g. <img type="optin" data-category="marketing" data-src="https://via.placeholder.com/300x300">) 0.0.4 Added possibility to add an imprint link to the banner 0.0.3 Multi-language support for module config (still in development) 0.0.2 First release 0.0.1 Early development
    • By bernhard
      --- Please use RockFinder3 ---
    • By MoritzLost
      Cacheable Placeholders
      This module allows you to have pieces of dynamic content inside cached output. This aims to solve the common problem of having a mostly cacheable site, but with pieces of dynamic output here and there.  Consider this simple example, where you want to output a custom greeting to the current user:
      <h1>Good morning, <?= ucfirst($user->name) ?></h1> This snippet means you can't use the template cache (at least for logged-in users), because each user has a different name. Even if 99% of your output is static, you can only cache the pieces that you know won't include this personal greeting. A more common example would be CSRF tokens for HTML forms - those need to be unique by definition, so you can't cache the form wholesale.
      This module solves this problem by introducing cacheable placeholders - small placeholder tokens that get replaced during every request. The replacement is done inside a Page::render hook so it runs during every request, even if the response is served from the template cache. So you can use something like this:
      <h1>Good morning, {{{greeting}}}</h1> Replacement tokens are defined with a callback function that produces the appropriate output and added to the module through a simple hook:
      // site/ready.php wire()->addHookAfter('CachePlaceholders::getTokens', function (HookEvent $e) { $tokens = $e->return; $tokens['greeting'] = [ 'callback' => function (array $tokenData) { return ucfirst(wire('user')->name); } ]; $e->return = $tokens; }); Tokens can also include parameters that are parsed and passed to the callback function. There are more fully annotated examples and step-by-step instructions in the README on Github!
      Features
      A simple and fast token parser that calls the appropriate callback and runs automatically. Tokens may include multiple named or positional parameters, as well as multi-value parameters. A manual mode that allows you to replace tokens in custom pieces of cached content (useful if you're using the $cache API). Some built-in tokens for common use-cases: CSRF-Tokens, replacing values from superglobals and producing random hexadecimal strings. The token format is completely customizable, all delimiters can be changed to avoid collisions with existing tag parsers or template languages. Links
      Github Repository & documentation Module directory (pending approval) If you are interested in learning more, the README is very extensive, with more usage examples, code samples and usage instructions!
    • By Craig
      I've been using Fathom Analytics for a while now and on a growing number of sites, so thought it was about time there was a PW module for it.
      WayFathomAnalytics
      WayFathomAnalytics is a group of modules which will allow you to view your Fathom Analytics dashboard in the PW admin panel and (optionally) automatically add and configure the tracking code on front-end pages.
      Links
      GitHub Readme & documentation Download Zip Modules directory Module settings screenshot What is Fathom Analytics?
      Fathom Analytics is a simple, privacy-focused website analytics tool for bloggers and businesses.

      Stop scrolling through pages of reports and collecting gobs of personal data about your visitors, both of which you probably don't need. Fathom is a simple and private website analytics platform that lets you focus on what's important: your business.
      Privacy focused Fast-loading dashboards, all data is on a single screen Easy to get what you need, no training required Unlimited email reports Private or public dashboard sharing Cookie notices not required (it doesn't use cookies or collect personal data) Displays: top content, top referrers, top goals and more
×
×
  • Create New...