Jump to content

Phone Number Fieldtype


adrian

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?

  • 1.0.8/ no
  • yes
Link to comment
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!

Link to comment
Share on other sites

  • 10 months later...

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.

Link to comment
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?

Link to comment
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?

Link to comment
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?

Link to comment
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?

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

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

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

Link to comment
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
Link to comment
Share on other sites

  • 1 month later...

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.

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

Link to comment
Share on other sites

  • 2 weeks later...

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?

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

Link to comment
Share on other sites

  • 10 months later...

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