Jump to content

PageSelect in Register / Profile


joeck
 Share

Recommended Posts

Hi there,

I'm trying to have a PageReference (single) Select field in the registration form and profile page of the user.

I'm trying to achieve this with the module LoginRegister: https://modules.processwire.com/modules/login-register/
I simply added the desired field (team) to the user template and then added the field to the field selection in the module configuration.
but the select doesn't render properly (see image attached).

I'm assuming the reason is because the PageSelect field isn't text-based:
 

Quote

You should stick to using simple text-based fields for now. File/image fields, repeaters, rich text editors and combination fields fields are not supported on the front-end at present.

I tried to add the InputFieldPage field to the form manually but only got the error that the field needs to be configured.
Even with this blog 

or this one:

I wasn't able to get the Select displaying correctly.

This is a very strange and new feeling for me: searching a functionality in Processwire for more than a day and not being able to find a very easy and smart solution.
Can someone point me into the right direction?

team_render.png

Link to comment
Share on other sites

Just installed Login/Register/Profile module, created a page reference field and a select options field to test, added both fields to the user template and the module settings, added the module code to a template and it worked.

Maybe me screenshots help in some way.

Screenshot-20190513-162744.thumb.png.c1e18f207906dc2efdd4f024f59e1a0e.pngScreenshot-20190513-162752.thumb.png.a9458eae2afeb3b0547427da33c7dcbd.pngScreenshot-20190513-162811.png.0caef11446c438ccaf49194ae310169b.png

  • Like 2
Link to comment
Share on other sites

You're welcome. ?

I wouldn't create a fresh installation... just start taking things apart.

Check your page reference field. Maybe there are no pages, maybe they are hidden, maybe your input type is wrong, maybe whatever.

Screenshot-20190513-164031.png.055d98e533db53e836d00fbbbecc144a.png

Check if you added the field to the user template and to the module settings.

Try another browser, delete your cache... if there were any errors they should show up. Maybe you will find something in your dev console.

Link to comment
Share on other sites

oh boy,

turns out that my css library materialize.css sets all the select inputs to display: none ?
The select has all the desired data simply not visible due to css...

But now i get another error when trying to register with a new account:
Fatal error: Uncaught Exception: Serialization of 'Closure' is not allowed in [no active file]:0 Stack trace: #0 {main} thrown in [no active file] on line 0
Again no logs in Processwire admin or browser console.

The registration email actually gets sent out but when you click the link you receive the error message:
Unable to complete confirmation, please re-register and try again.

fatal_error.png

Link to comment
Share on other sites

yes I have a hook in ready.php that should only apply on a different PageSelect field called team_owner:

$wire->addHookAfter('InputfieldPage::getSelectablePages', function($event) {
  if($event->object->hasField == 'team_owner' && !$this->wire('user')->isSuperUser()) {
    $permissions = $this->wire('user')->getPermissions();
    $authorized_pages = new PageArray();
    foreach($permissions as $permission){
      if (!$permission->team_owner) { continue; } //skip permissions without team
      foreach($event->pages->find("template=team") as $page){
          if ($page === $permission->team_owner){
              $authorized_pages->add($page);
          }
      }
    }
    $event->return = $authorized_pages;
  }
});

I think this is working as desired, since I see all the options in the dropdown of the registration form field (called team_reference) and if the hook would execute I shouldn't see all the fields in the dropdown.

these modules are installled:
AdminOnSteroids
FieldtypeColorPicker
InputfieldCKEditor
LoginRegister
PageEditFieldPermission
TracyDebugger

fullcalender.io (not a processwire module)

Link to comment
Share on other sites

I don't know if this hook causes the error. Test the registration without that hook to confirm it.

Your modules seem to be fine - I guess.

Unless you don't use a weird setup with nginx or frameworks of any kind (no, not materialize.css ?) I have no idea where this comes from.

 

Link to comment
Share on other sites

I removed the hook but error message still shows.
I don't have any setup with nginx or other framework (apart from jQuery but I assume that is not considered weird, nor a framework)

Tracy is on version 4.19.13 and apparently up-to-date.
No recent tracy logs

I haven't found any serialize() in my code and I'm pretty sure I didn't use it since this is the first time I hear about this function, let alone knowing what it does.

Link to comment
Share on other sites

update:
If I remove the pageSelect field from the registration form the error no longer shows but the registration process is still not working (not sure why)

The problem seems to be on the registration form only. Profile edit works just fine with the pageSelect field.

  • 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...