Jump to content

Login/Register - custom field saving issue


JeevanisM
 Share

Recommended Posts

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.

image.thumb.png.f40f3d23d3f8849fdf15e13a06ef63b6.png

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

 

image.png.eee59c5c952dd521d71cb1dd8d23cd22.png

Link to comment
Share on other sites

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 by kixe
Added comment about the value of FieldtypePhone
  • Like 1
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...