Jump to content

Cannot select users in page field


bernhard
 Share

Recommended Posts

Hey!

I have a strange problem with a pagefield. As SuperUser everything works fine, but as "admin" I cannot select the "client" for a "training":

NIiRrNe.png

The field is set to this:

IEVQrUR.png

And the label field is "fullname". As SuperUser it just works fine:

N9B8IIs.png

And the search also works (as admin):

8PzTx6L.png

Any ideas?

Link to comment
Share on other sites

You will also come up agains this: https://github.com/processwire/processwire-issues/issues/550

This will fix that issue:

$this->addHookBefore('Pages::find', function(HookEvent $event) {
    $selector = $event->arguments(0);
    if(is_string($selector) && strpos($selector, 'template=user') !== false && strpos($selector, 'name|first_name|last_name%=') !== false) {
        $selector .= ', check_access=0';
    }
    $event->arguments(0, $selector);
});

PS - you might need to adjust the modified selector to suit your needs - re the first_name, last_name etc

  • Like 5
  • Thanks 1
Link to comment
Share on other sites

  • 3 years later...

This is still an issue.
I cannot select a user from an auto complete select on an admin form. Even with the hooks @adrian and @bernhardsuggested in this reported issue.

My select field is configured as follows:
Page field value type = single/false (other options make no difference).
Allow unpublished pages = checked.
Type: Page auto complete.
Template = User.
Selector string = template=user, include=all, check_access=0, sort=name.
Label field = name.

When attempting to edit a page with this field this is the resulting selector:

  template=user, sort=title, templates_id=3, title%=sca, limit=50
 

*Notice the duplicate template reference. This obviously is a core issue.

 

The resulting query is:

SELECT SQL_CALC_FOUND_ROWS pages.id,pages.parent_id,pages.templates_id FROM `pages` JOIN field_title AS field_title ON field_title.pages_id=pages.id AND (((field_title.data LIKE '%sca%' ) )) LEFT JOIN field_title AS _sort_title ON _sort_title.pages_id=pages.id WHERE (pages.templates_id=3) AND (pages.templates_id=3) GROUP BY pages.id ORDER BY _sort_title.data LIMIT 0,50

Two issues with this query; 1) there are no user names present in the field_title.data column, 2) the join statement has three levels of parens, which are obviously leftover from from whatever concatenation function that was previously performed. This again is a core issue.

All of my projects rely on selecting a user at various steps.

Can anyone provide a workaround, or tell me what I have done wrong?

I appreciate your input.

 

Link to comment
Share on other sites

Thank you @adrian, I did not see that. I appreciate you locating that topic. I have it saved for future reference.

In the meantime I came up with a workaround where I don't have to modify a user's ready.php file during install.

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