Jump to content
adrian

Phone Number Fieldtype

Recommended Posts

What version of FieldtypePhone did you initially install? Was it before the update that I mention in post #25 above?

Does saving the module's config settings fix the error?

Share this post


Link to post
Share on other sites

What version of FieldtypePhone did you initially install? Was it before the update that I mention in post #25 above?

Does saving the module's config settings fix the error?

  • 1.0.8/ no
  • yes

Share this post


Link to post
Share on other sites

I am having trouble figuring out why this would happen. When I install the module the config setting are automatically populated to the modules DB table. 

If you have a minute would you mind uninstalling and reinstalling and see if the error shows up again, and also post the contents of the data field from the modules DB table.

Thanks!

Share this post


Link to post
Share on other sites

No troubles any more. Maybe there where some old settings stored, because I used an older version of that field before. Its working fine after uninstalling/reinstalling.

  • Like 1

Share this post


Link to post
Share on other sites

I have a problem setting the field as mandatory. I get allways a warning that its not set.

Hi @Spica,

Interesting that no-one has reported that until now :)

Anyway, it should be fixed in the latest version. Please let me know how it goes for you and thanks for the report.

BTW - I made it so that only the "number" portion of the field is considered for the required check.

Share this post


Link to post
Share on other sites

Yes, was confused about that too and first tested for an installation problem. But now its working. Thanks.

Btw. I changed the input type to

type='text' pattern='[0-9]*'

as the type number does not allow a leading zero (which is necessary for me) and has this up and down ticks, that do not make sense to me for telefonenumbers. This makes updating harder in future. Mayby the input type is selectable in a next version?

Share this post


Link to post
Share on other sites

Next Problem. Have this output Format

{+[phoneCountry] }{([phoneAreaCode,0,0]) }{[phoneAreaCode,1,5] }{[phoneNumber]}{–[phoneExtension]}

it should give e.g.

+49 (0) 30 1111-22

but actually gives

+49 30 1111-22

The Mobile (unformatted) output should give

+4930111122

and not

+49030111122

How to handle that best way?

Share this post


Link to post
Share on other sites

@Spica,

I have changed the number format to text with that pattern - I don't really see any downsides at the moment. So that should handle you leading zero issue.

As for the format option. I don't really understand what you expect:

{([phoneAreaCode,0,0]) }

to return. PHP substr() won't return anything with this because you are starting at 0 and returning 0 characters. Does that number always need to be: 0 or will it be different?

Perhaps you could also provide with with the numbers you entered in each phone component to get the results you are getting?

I am also confused about your use of the extension component. At least where I am from, this is not something that is dialed initially, but is entered after the call has been connected to get a certain phone is an office. Note the other example formats where I split the main number component into parts either side of a dash. Is this what you are trying to achieve.

I haven't looked at this module in a while, but I am thinking that perhaps I should make it possible to set the format for each phone field, rather than in the config settings with a user override. I think a dev override in the field settings might be more useful - this would allow for different formats for landline vs mobile(cell) numbers. Any thoughts?

Share this post


Link to post
Share on other sites

Your right, my mistake in transcription. Should be

{([phoneAreaCode,0,1]) }

But it seems, that the single 0 is interpreted as a non value.

It is for German city codes, that start always with a 0. So there is a notation convention to note the 0 in brackets, if the country code is also notated. A call within Germany needs the leading 0. A call with the country code dialed first makes it obsolete, so I need to supress it for the unformatted output.

I could put the 0 into the pattern, but this may confuse users with the input as they my try to note the 0.

The extention code is also dialed directly and leads from the main connection to certain phones/offices and is divided by a divice, but dialed in once with the whole number. The divice is only a visual hint. As it is not standarized how many numbers a mainline and a extension has, I cant divide it by a pattern but need the fields.

So my main problem right now is how to get the leading 0 and I would be able to note my numbers. It only has to do with the local notation convention. For mobile numbers you can already disable the extension in the field settings, or just leave it out. But I thought maby us the field as a repeatable field, so it would be nice to chose the format for each entry while input it?

Share this post


Link to post
Share on other sites

Thanks very much for the detailed explanation about German phone formats, especially the leading (0) and also the extension - very helpful.

I have fixed the bug with the "(0)" not being displayed - please let me know if the new version works for you now.

But I thought maby us the field as a repeatable field, so it would be nice to chose the format for each entry while input it?

If I understand you correctly, this is already possible - go to the phone field setting's Input tab and check "Output Format Override" - this will give your site editors the ability to choose from the available formats as defined in the config settings. I think I will also look into having that option for the developer to set the format per field as well though.

Share this post


Link to post
Share on other sites

Thanks, adrian,

version works now for me very well.

I already noticed the output format override, which already would be a good solution. But I thought of more convenience for users not to even get a extention input field when they want to add a cell number. Dont know if this anyhow makes sense.

Share this post


Link to post
Share on other sites

version works now for me very well.

Great!

I already noticed the output format override, which already would be a good solution. But I thought of more convenience for users not to even get a extention input field when they want to add a cell number. Dont know if this anyhow makes sense.

What about the field specific "Extension: (Whether to ask for extension when entering phone numbers.)" checkbox - uncheck that to remove the extension input? I guess the problem is with using this in a repeater because you are using the same field. I guess the new Repeater Matrix pro field would be a good solution. Otherwise you could use a PageTable field, but obviously not as nice of a UI for this.

Share this post


Link to post
Share on other sites

Havent used the Repeater Matrix pro yet. PageTable seem too make the gui more complex as needed. Checkbox would be nice to toggle the extension on/off. But ist not a must have.

Share this post


Link to post
Share on other sites

I have just added the option to define the phone output format on the Input tab of each phone field's settings. This should make it much nicer if you have separate fields for landline and mobile numbers, etc.

Share this post


Link to post
Share on other sites

Oh, I ve forgotten the cell output which needs the leading 0 stripped for an autom. call. Can do it in the template or do you see an adaption into your module?

will check the new version immediately.

Share this post


Link to post
Share on other sites

Oh, I ve forgotten the cell output which needs the leading 0 stripped for an autom. call. Can do it in the template or do you see an adaption into your module?

I think this might best be handled in your template as getting into having multiple formatted versions for each phone field in the module might get a little out of control.

All you would need to do is build the number like this:

$automaticDial = '+' . $page->phone->country . ' ' . ltrim($page->phone->area_code, "0") . $page->phone->number;

Or something like that - I am sure you get the idea :)

  • Like 1

Share this post


Link to post
Share on other sites

I am continuously getting the same error flagged.

Notice: Trying to get property of non-object in /home/djverde/public_html/site/modules/FieldtypePhone/InputfieldPhone.module on line 140

Fatal error: Call to a member function set() on a non-object in /home/djverde/public_html/site/modules/FieldtypePhone/InputfieldPhone.module on line 145

Do you have any ideas what I could be doing wrong. I have checked again and again, re-read the documentation countless times. Still can not see what I have done wrong.

If you need any more information let me know.

I have just today updated to the latest version and the issue persists.

Share this post


Link to post
Share on other sites

Hi @MikeB,

Sorry that you are seeing those errors. I can't figure out why here at the moment. I could add a check to make sure that $value is an object before the code on lines 140 and 145 is processed, but I would like to be able to replicate what you are seeing first. Presumably you are getting this error when saving a page with this template in the admin? Is the phone field in a normal template, or is it part of repeater, or some other combined field situation?

Let me know more and I am sure this will be an easy fix.

PS - I am on the road at the moment, so forgive me if my responses are delayed.

Share this post


Link to post
Share on other sites

I have used the field in a formbuilder form.

I get the error if I complete the field on submission of the form.

If I leave the field blank (It is optional) I get no error.

Hope this helps you track it down.

Anything else I can send you to aid in debugging?

Share this post


Link to post
Share on other sites

I believe that FormBuilder is not compatible with every Fieldtype and that may be the cause of your problem. 

  • Like 2

Share this post


Link to post
Share on other sites

I believe that FormBuilder is not compatible with every Fieldtype and that may be the cause of your problem. 

Mike - I am not a FormBuilder user so I am not sure if this is a FB issue or if there is something that I can change in the Phone fieldtype to make it work with FB. Perhaps if you post about this in the FB thread, Ryan might have some advice.

Share this post


Link to post
Share on other sites

I have a problem with the " Extension-Field".

I can not save a single "0" as extension. When i enter a single 0 and save the page the field is empty. Any other number works as expected even when i enter "00" but a single "0" is not saved.

Here in germany many phonenumbers use a single "0" as extension:

Example:

Phone: +49 (421) 123456 - 0
Fax: +49 (421) 123456 - 1

  • Like 1

Share this post


Link to post
Share on other sites

Hi @Roman Schmitz - sorry about that!

I will commit a fix a little later (I want to clean up some other stuff while I am at it), but for now please change: https://github.com/adrianbj/FieldtypePhone/blob/56ec89e7fc81cdc693ce72f9f9030edf3f49bd63/FieldtypePhone.module#L159

to:

if($value['data_extension'] != '') $pn->extension = wire('sanitizer')->text($value['data_extension']);

 

  • Like 4

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By gebeer
      I am happy to present my new fieldtype FieldtypeImageFromPage. It is made up of 2 modules:
      Fieldtype Image Reference From Another Page is a Fieldtype that stores a reference to a single image from another page. The image can be selected with the associated Inputfield.
      Inputfield Select Image From Page is an Inputfield to select a single image from images on a predefined page and it's children.
      And there also is a helper module that takes care of cleanup tasks.
      This module evolved out of a discussion about my other Module FieldtypeImagePicker.  It caters for use cases where a set of images is being reused multiple times across a site. With this fieldtype these images can be administered through a chosen page. All images uploaded to that page will be available in the inputfield.
      When to use ?
      Let editors choose an image from a set of images that is being used site-wide. Ideal for images that are being re-used across the site.
      Suited for images that are used on multiple pages throughout the site (e.g. icons).
      Other than the native ProcessWire images field, the images here are not stored per page. Only references to images on another page are stored. This has several advantages:
      one central place to organize images when images change, you only have to update them in one place. All references will be updated, too. (Provided the name of the image that has changed stays the same) Features
      Images can be manipulated like native ProcessWire images (resizing, cropping etc.) Image names are fully searchable through the API Accidental image deletion is prevented. When you want to delete an image from one of the pages that hold your site-wide images, the module searches all pages that use that image. If any page contains a reference to the image you are trying to delete, deletion will be prevented. You will get an error message to help you edit those pages and remove references there before you can finally delete the image. How to install and setup
      Download and install this module like any other modules in ProcessWire Create a page in the page tree that will hold your images. This page's template must have an images field Upload some images to the page you created in step 2 Create a new field. As type choose 'Image Reference From Another Page'. Save the field. In 'Details' Tab of the field choose the page you created in step 2 Click Save button Choose the images field name for the field that holds your images (on page template from step 2) Click Save button again Choose whether you want to include child pages of page from step 2 to supply images Add the field to any template You are now ready to use the field View of the inputfield on the page edit screen:

      View of the field settings

      The module can be installed from this github repo. Some more info in the README there, too.
      In my tests it was fairly stable. After receiving your valued feedback, I will eventually add it to the modules directory.
      My ideas for further improvement:
      - add ajax loading of thumbnails
      Happy to hear your feedback!
       
    • By gebeer
      Although the PW backend is really intuitive, ever so often my clients need some assistance. Be it they are not so tech savvy or they are not working in the backend often.
      For those cases it is nice to make some help videos available to editors. This is what this module does.
      ProcessHelpVideos Module
      A Process module to display help videos for the ProcessWire CMS. It can be used to make help videos (screencasts) available to content editors.
      This module adds a 'Help Videos" section to the ProcessWire backend. The help videos are accessible through an automatically created page in the Admin page tree. You can add your help videos as pages in the page tree. The module adds a hidden page to the page tree that acts as parent page for the help video pages. All necessary fields and templates will be installed automatically. If there are already a CKEditor field and/or a file field for mp4 files installed in the system, the module will use those. Otherwise it will create the necessary fields. Also the necessary templates for the parent help videos page and it's children are created on module install. The module installs a permission process-helpvideos. Every user role that should have access to the help video section, needs this permission. I use the help video approach on quite a few production sites. It is stable so far and well received by site owners/editors. Up until now I installed required fields, templates and pages manually and then added the module. Now I added all this logic to the install method of the module and it should be ready to share.
      The module and further description on how to use it is available on github: https://github.com/gebeer/ProcessHelpVideos
      If you like to give it a try, I am happy to receive your comments/suggestions here.
    • By Robin S
      A module created in response to the topic here:
      Page List Select Multiple Quickly
      Modifies PageListSelectMultiple to allow you to select multiple pages without the tree closing every time you select a page.
      The screencast says it all:

       
      https://github.com/Toutouwai/PageListSelectMultipleQuickly
      https://modules.processwire.com/modules/page-list-select-multiple-quickly/
    • By gebeer
      Hello all,
      sharing my new module FieldtypeImagePicker. It provides a configurable input field for choosing any type of image from a predefined folder.
      The need for it came up because a client had a custom SVG icon set and I wanted the editors to be able to choose an icon in the page editor.
      It can also be used to offer a choice of images that are used site-wide without having to upload them to individual pages.
      There are no image manipulation methods like with the native PW image field.
      Module and full description can be found on github https://github.com/gebeer/FieldtypeImagePicker
      Kudos to @Martijn Geerts. I used his module FieldTypeSelectFile as a base to build upon.
      Here's how the input field looks like in the page editor:

      Hope it can be of use to someone.
      If you like to give it a try, I'm happy to hear your comments or suggestions for improvement. Eventually this will go in the module directory soon, too.
    • By bernhard
      @Sergio asked about the pdf creation process in the showcase thread about my 360° feedback/survey tool and so I went ahead and set my little pdf helper module to public.
      Description from PW Weekly:
       
      Modules Directory: https://modules.processwire.com/modules/rock-pdf/
      Download & Docs: https://github.com/BernhardBaumrock/RockPDF
       
      You can combine it easily with RockReplacer: 
      See also a little showcase of the RockPdf module in this thread:
       
×
×
  • Create New...