Jump to content

Custom Field


rareyush
 Share

Recommended Posts

On 3/17/2018 at 10:50 PM, elabx said:

Why don't you have a text field in the category page you just created? After created, you can click the title (if using ASM Select for example) to open the page and add more content.

text field won't work here because when user select create new I want to show 2 text fields there.

Link to comment
Share on other sites

You could also use a Page Table (ProFields), available in ProcessWire's core and freely installable from the backend.
You can select a parent for the items (unlike repeaters), enter the table fields you want to display in the administration panel...

You could perhaps also use a Page Reference Field, choose a way of selecting that suits you, select a parent page with children pages that only have the fields you need...

Edited by Christophe
  • Like 1
Link to comment
Share on other sites

  • 1 year later...

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

What does tracy debugger show:

$u = wire('users')->get("name=saarun");
d($u);
d($u->Phone); // dump content of your fields

When you view the user while in admin, what does that page look like? By that I mean you should see all the fields for the user template and the field's current values. If the field (for example, Phone) is empty, then there is an issue with saving the data to the page. Most likely the data is not the correct format.

Do the logs display any information?

Link to comment
Share on other sites

16 hours ago, rick said:

What does tracy debugger show:


$u = wire('users')->get("name=saarun");
d($u);
d($u->Phone); // dump content of your fields

When you view the user while in admin, what does that page look like? By that I mean you should see all the fields for the user template and the field's current values. If the field (for example, Phone) is empty, then there is an issue with saving the data to the page. Most likely the data is not the correct format.

Do the logs display any information?

Hello @rick

 

thank you for replying me. I will explain step by step what I have done and what is my requirement.

1. I have a user registration form built on Login/Register module in which I need to save the user telephone along with username/password. As a default, login/Register module only have email, password fields in the registration form. so I need a phone number field there too.

2. so I searched and found there is a module called Phone Field type, I installed and created a new field using that type. I dont need any fancy feature, just need 10 digits without any country code or extensions

3. then I added this new field to the user template, then I opened the Login/Register module configuration and added those this phone field

4. I saved everything, and I went to registration form, in which I can see the new phone field entering form

5. I registered, with email, pass and phone number

6. But when I tried to output the phone number its empty, so I went to the users page in admin section and check if the number is saved. But its not saved.

7. so I tried to save it from the admin/access/users page, and then I checked it via outputing, now its working. So the field is not getting saved from the registration step.
8. so I thought this must be some conflict with login/register module and the phone field type module.

9. so I created a new standard Integer field, and labelled it for phone

10. I added this new field to user template > then login/user field to the registration page

11. Before I register from frontend, I tried to save the phone number from the admin/access page but I got an SQL error

Error saving field "userphone" - SQLSTATE[22003]: Numeric value out of range: 1264 Out of range value for column 'data' at row 1 +1

Now I am clueless, what to next ?

How do I create a standard integer phone number field ? or why  the Login/Register module is not taking the phone type

Link to comment
Share on other sites

Hi @JeevanisM,

It is difficult to say what the problem is without having the code you are using. Based on what you describe, if the value of the phone number is not being saved from your form, then it may be something as simple as a misspelled field name. Please post your registration form code so that we can better assist you in resolving this issue.

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

×
×
  • Create New...