Jump to content
Sign in to follow this  
rareyush

Custom Field

Recommended Posts

I am trying too create a custom field where when user select to create a category 2 text area shows where one title of the category goes & another for some content.

Like in a picture I want 2 text areas when I click on create new

oi.PNG

Share this post


Link to post
Share on other sites

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.

Share this post


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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

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

Share this post


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

Share this post


Link to post
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

Share this post


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

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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Pip
      Hi, Everyone! 
      I'm currently working on a page reference field and set it for multiple pages (AsmSelect) for the input. Is there a way for me to add an image field (aka Avatar) and the title of page in the radio button? 
      I used the field name enclosed in the { }. Didn't work. It appeared a text instead. 
      Thanks in advance and hope to hear from you soon!
    • By calago
      after the migration to version 3.0.145 our export templates all of a sudden dont work properly, 
      we have a functionality where we use a boiler template with a set of fields. for some reason since the upgrade when we select the export template to export it. it wont show any of the fields added after the migration, 

      as you can see the offer certificate remarks field has been added to the export, 
      but when we select it it wont come trough

    • By EyeDentify
      Hello dear PW gurus.

      I have stumbled over a strange error that i all of sudden got when trying to upload an image to a images field on a page.
      There where images allready stored in the field that i wanted to keep, but during the upload the error apear and after that all images are gone from the field and i can´t upload any, i just get the error every time.
      I am running ProcessWire 3.0.153 dev.
      Update:
      After looking in the assets folder i find the folder for the page and the image files seems to be there including the ones i tried to upload when the error occured.
      But they don´t show up in the images field in the page editor.
       
      The error reported:
       
      SQLSTATE[01000]: Warning: 1265 Data truncated for column 'ratio' at row 1 And here is a screenshot of the event:

      The TracyDebugger Error reporting:

      I hope you fine folks could point me in a direction.
      But it seems our old pal set_time_limit() is back.

      Regards, EyeDentify
    • By Robin S
      A new module that hasn't had a lot of testing yet. Please do your own testing before deploying on any production website.
      Custom Paths
      Allows any page to have a custom path/URL.
      Screenshot

      Usage
      The module creates a field named custom_path on install. Add the custom_path field to the template of any page you want to set a custom path for. Whatever path is entered into this field determines the path and URL of the page ($page->path and $page->url). Page numbers and URL segments are supported if these are enabled for the template, and previous custom paths are managed by PagePathHistory if that module is installed.
      The custom_path field appears on the Settings tab in Page Edit by default but there is an option in the module configuration to disable this if you want to position the field among the other template fields.
      If the custom_path field is populated for a page it should be a path that is relative to the site root and that starts with a forward slash. The module prevents the same custom path being set for more than one page.
      The custom_path value takes precedence over any ProcessWire path. You can even override the Home page by setting a custom path of "/" for a page.
      It is highly recommended to set access controls on the custom_path field so that only privileged roles can edit it: superuser-only is recommended.
      It is up to the user to set and maintain suitable custom paths for any pages where the module is in use. Make sure your custom paths are compatible with ProcessWire's $config and .htaccess settings, and if you are basing the custom path on the names of parent pages you will probably want to have a strategy for updating custom paths if parent pages are renamed or moved.
      Example hooks to Pages::saveReady
      You might want to use a Pages::saveReady hook to automatically set the custom path for some pages. Below are a couple of examples.
      1. In this example the start of the custom path is fixed but the end of the path will update dynamically according to the name of the page:
      $pages->addHookAfter('saveReady', function(HookEvent $event) { $page = $event->arguments(0); if($page->template == 'my_template') { $page->custom_path = "/some-custom/path-segments/$page->name/"; } }); 2. The Custom Paths module adds a new Page::realPath method/property that can be used to get the "real" ProcessWire path to a page that might have a custom path set. In this example the custom path for news items is derived from the real ProcessWire path but a parent named "news-items" is removed:
      $pages->addHookAfter('saveReady', function(HookEvent $event) { $page = $event->arguments(0); if($page->template == 'news_item') { $page->custom_path = str_replace('/news-items/', '/', $page->realPath); } }); Caveats
      The custom paths will be used automatically for links created in CKEditor fields, but if you have the "link abstraction" option enabled for CKEditor fields (Details > Markup/HTML (Content Type) > HTML Options) then you will see notices from MarkupQA warning you that it is unable to resolve the links.
      Installation
      Install the Custom Paths module.
      Uninstallation
      The custom_path field is not automatically deleted when the module is uninstalled. You can delete it manually if the field is no longer needed.
       
      https://github.com/Toutouwai/CustomPaths
      https://modules.processwire.com/modules/custom-paths/
    • By DV-JF
      Hey all, hope you're feeling well these days!
      Short question: Under "Setup > Templates" it's possible to sort the templates by last modified. Is this possible for fields view to?
      Long explanation:
      Currently I am in the process of programming a reusable template and often have to copy several fields & templates from different PW installations into my "master version".
      Therefore it would be good to see already in the field list when the last modification has taken place.
      Stay healthy & don't forget to wash you hands - many greets!
×
×
  • Create New...