JeevanisM Posted November 9, 2019 Share Posted November 9, 2019 Hello, I have created a standard field type as userphone , then I added this field to the User template. I created a phone field type using Phone Field module. I added this field to the User template also. Now I used the below to create a test user $u = new User(); $u->of(false); $u->name = "saarun"; $u->email = "saarunthomas@example.com"; $u->pass = "123456"; $u->Phone = 9446196667; $u->userphone = 9446196667; $u->headline = "hello there"; $u->paid=1; $u->addRole("registered"); $u->save(); $u->of(true); and I tried to out put as below $item = $users->get("saarun"); echo $item->email; echo $item->Phone; echo $item->paid; echo $item->headline; echo $item->userphone; and I got the output a below. Neither the userphone value nor the Phone value are output ... what am I doing here wrong ? pls help Link to comment Share on other sites More sharing options...
kixe Posted November 11, 2019 Share Posted November 11, 2019 (edited) Do not use FieldtypeInteger for Phonenumbers, because the Mysql Datatype is INT and therefore the value is limited to 4 bytes strings (32bit). You can use FieldtypeInteger only for numbers within the range from -2147483647 to 2147483647. Use builtin FieldtypeText or FieldtypePhone (3d Party Module) for Phonenumbers. The value of FieldtypePhone must be an instance of Phone (WireData derived object) otherwise it will be set to blank value. From the code: /** * If value not of instance Phone return empty instance */ Edited November 11, 2019 by kixe Added comment about the value of FieldtypePhone 1 Link to comment Share on other sites More sharing options...
adrian Posted November 11, 2019 Share Posted November 11, 2019 Wow - another post about this - I deleted one already ? Please see my response here: https://processwire.com/talk/topic/4388-phone-number-fieldtype/?do=findComment&comment=193502 about how to set values for FieldtypePhone fields. 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now