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.

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

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 Gadgetto
      SnipWire - Snipcart integration for ProcessWire
      Snipcart is a powerful 3rd party, developer-first HTML/JavaScript shopping cart platform. SnipWire is the missing link between Snipcart and the content management framework ProcessWire.
      With SnipWire, you can quickly turn any ProcessWire site into a Snipcart online shop. The SnipWire plugin helps you to get your store up and running in no time. Detailed knowledge of the Snipcart system is not required.
      SnipWire is free and open source licensed under Mozilla Public License 2.0! A lot of work and effort has gone into development. It would be nice if you could donate an amount to support further development:

      Status update links (inside this thread) for SnipWire development
      2020-07-03 -- SnipWire 0.8.7 (beta) released! Fixes some small bugs and adds an indicator for TEST mode 2020-04-06 -- SnipWire 0.8.6 (beta) released! Adds support for Snipcart subscriptions and also fixes some problems 2020-03-21 -- SnipWire 0.8.5 (beta) released! Improves SnipWires webhooks interface and provides some other fixes and additions 2020-03-03 -- SnipWire 0.8.4 (beta) released! Improves compatibility for Windows based Systems. 2020-03-01 -- SnipWire 0.8.3 (beta) released! The installation and uninstallation process has been heavily revised. 2020-02-08 -- SnipWire 0.8.2 (beta) released! Added a feature to change the cart and catalogue currency by GET, POST or SESSION param 2020-02-03 -- SnipWire 0.8.1 (beta) released! All custom classes moved into their own namespaces. 2020-02-01 -- SnipWire is now available via ProcessWire's module directory! 2020-01-30 -- SnipWire 0.8.0 (beta) first public release! (module just submitted to the PW modules directory) 2020-01-28 -- added Custom Order Fields feature (first SnipWire release version is near!) 2020-01-21 -- Snipcart v3 - when will the new cart system be implemented? 2020-01-19 -- integrated taxes provider finished (+ very flexible shipping taxes handling) 2020-01-14 -- new date range picker, discount editor, order notifiactions, order statuses, and more ... 2019-11-15 -- orders filter, order details, download + resend invoices, refunds 2019-10-18 -- list filters, REST API improvements, new docs platform, and more ... 2019-08-08 -- dashboard interface, currency selector, managing Orders, Customers and Products, Added a WireTabs, refinded caching behavior 2019-06-15 -- taxes provider, shop templates update, multiCURL implementation, and more ... 2019-06-02 -- FieldtypeSnipWireTaxSelector 2019-05-25 -- SnipWire will be free and open source Plugin Key Features
      Fast and simple store setup Full integration of the Snipcart dashboard into the ProcessWire backend (no need to leave the ProcessWire admin area) Browse and manage orders, customers, discounts, abandoned carts, and more Multi currency support Custom order and cart fields Process refunds and send customer notifications from within the ProcessWire backend Process Abandoned Carts + sending messages to customers from within the ProcessWire backend Complete Snipcart webhooks integration (all events are hookable via ProcessWire hooks) Integrated taxes provider (which is more flexible then Snipcart own provider) Useful Links
      SnipWire in PW modules directory SnipWire Docs (please note that the documentation is a work in progress) SnipWire @GitHub (feature requests and suggestions for improvement are welcome - I also accept pull requests) Snipcart Website  

       
      ---- INITIAL POST FROM 2019-05-25 ----
       
    • By Sten
      Hello
      Till now I hacked something with the twig template but it works no more with new PW versions so I look forward to create a module. I am working on a site in multiple languages : French, English, Italian, German, Spanish, Portuguese, Hebrew, Russian. The new posts are entered in any language with a field for language. Till now, I got twig files to get the translations with constants defined for each part of the pages.
      So I'd like to create a module to include theses files added according to the url /fr/en/...
      Have you some observations to do before I begin about the direction to take ?
      Thank you
    • By ukyo
      Mystique Module for ProcessWire CMS/CMF
      Github repo : https://github.com/trk/Mystique
      Mystique module allow you to create dynamic fields and store dynamic fields data on database by using a config file.
      Requirements
      ProcessWire 3.0 or newer PHP 7.0 or newer FieldtypeMystique InputfieldMystique Installation
      Install the module from the modules directory:
      Via Composer:
      composer require trk/mystique Via git clone:
      cd your-processwire-project-folder/ cd site/modules/ git clone https://github.com/trk/Mystique.git Module in live reaction with your Mystique config file
      This mean if you remove a field from your config file, field will be removed from edit screen. As you see on youtube video.
      Using Mystique with your module or use different configs path, autoload need to be true for modules
      Default configs path is site/templates/configs/, and your config file name need to start with Mystique. and need to end with .php extension.
      Adding custom path not supporting anymore !
      // Add your custom path inside your module class`init` function, didn't tested outside public function init() { $path = __DIR__ . DIRECTORY_SEPARATOR . 'configs' . DIRECTORY_SEPARATOR; Mystique::add($path); } Mystique module will search site/modules/**/configs/Mystique.*.php and site/templates/Mystique.*.php paths for Mystique config files.
      All config files need to return a PHP ARRAY like examples.
      Usage almost same with ProcessWire Inputfield Api, only difference is set and showIf usage like on example.
      <?php namespace ProcessWire; /** * Resource : testing-mystique */ return [ 'title' => __('Testing Mystique'), 'fields' => [ 'text_field' => [ 'label' => __('You can use short named types'), 'description' => __('In file showIf working like example'), 'notes' => __('Also you can use $input->set() method'), 'type' => 'text', 'showIf' => [ 'another_text' => "=''" ], 'set' => [ 'showCount' => InputfieldText::showCountChars, 'maxlength' => 255 ], 'attr' => [ 'attr-foo' => 'bar', 'attr-bar' => 'foo' ] ], 'another_text' => [ 'label' => __('Another text field (default type is text)') ] ] ]; Example:
      site/templates/configs/Mystique.seo-fields.php <?php namespace ProcessWire; /** * Resource : seo-fields */ return [ 'title' => __('Seo fields'), 'fields' => [ 'window_title' => [ 'label' => __('Window title'), 'type' => Mystique::TEXT, // or InputfieldText 'useLanguages' => true, 'attr' => [ 'placeholder' => __('Enter a window title') ] ], 'navigation_title' => [ 'label' => __('Navigation title'), 'type' => Mystique::TEXT, // or InputfieldText 'useLanguages' => true, 'showIf' => [ 'window_title' => "!=''" ], 'attr' => [ 'placeholder' => __('Enter a navigation title') ] ], 'description' => [ 'label' => __('Description for search engines'), 'type' => Mystique::TEXTAREA, 'useLanguages' => true ], 'page_tpye' => [ 'label' => __('Type'), 'type' => Mystique::SELECT, 'options' => [ 'basic' => __('Basic page'), 'gallery' => __('Gallery'), 'blog' => __('Blog') ] ], 'show_on_nav' => [ 'label' => __('Display this page on navigation'), 'type' => Mystique::CHECKBOX ] ] ]; Searching data on Mystique field is limited. Because, Mystique saving data to database in json format. When you make search for Mystique field, operator not important. Operator will be changed with %= operator.
      Search example
      $navigationPages = pages()->find('my_mystique_field.show_on_nav=1'); $navigationPages = pages()->find('my_mystique_field.page_tpye=gallery');
    • By Robin S
      This is a module I made as an experiment a while ago and never got around to releasing publicly. At the time it was prompted by discussions around using Repeater fields for "page builder" purposes, where the depth feature could possibly be used for elements that would be nested inside other elements. I thought it would be useful to enforce some depth rules and translate the depth data into a multi-dimensional array structure.
      I'm not using this module anywhere myself but maybe it's useful to somebody.
      Repeater Depth Helper
      This module does two things relating to Repeater fields that have the "Item depth" option enabled:
      It enforces some depth rules for Repeater fields on save. Those rules are:
      The first item must have a depth of zero. Each item depth must not be more than one greater than previous item depth. It provides a RepeaterPageArray::getDepthStructure helper method that returns a nested depth structure for a Repeater field value.
      Helper method
      The module adds a RepeaterPageArray::getDepthStructure method that returns a multi-dimensional array where the key is the page ID and the value is an array of nested "child" items, or null if there are no nested children.
      Example

      The module doesn't make any assumptions about how you might want to use the depth structure array, but here is a way you might use it to output a nested unordered list.
      // Output a nested unordered list from a depth structure array function outputNestedList($depth_structure, $repeater_items) { $out = "<ul>"; foreach($depth_structure as $page_id => $nested_children) { $out .= "<li>" . $repeater_items->get("id=$page_id")->title; // Go recursive if there are nested children if(is_array($nested_children)) $out .= outputNestedList($nested_children, $repeater_items); $out .= "</li>"; } $out .= "</ul>"; return $out; } $repeater_items = $page->my_repeater; $depth_structure = $repeater_items->getDepthStructure(); echo outputNestedList($depth_structure, $repeater_items);
       
      https://github.com/Toutouwai/RepeaterDepthHelper
      https://modules.processwire.com/modules/repeater-depth-helper/
    • 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 If you are interested in learning more, the README is very extensive, with more usage examples, code samples and usage instructions!
×
×
  • Create New...