thetuningspoon Posted November 25, 2014 Share Posted November 25, 2014 I'm trying to create a page field which can select from any user on the site that is assigned the role "broker". I've setup the field as a basic select input and am using a custom selector (template=user, roles=broker) to display only the broker users. When I edit a page, the select drop down shows all of the correct users. However, if I try to select one and save the page I get the following error: Session: Error saving field "broker" - Page 1031 is not valid for broker Link to comment Share on other sites More sharing options...
adrian Posted November 25, 2014 Share Posted November 25, 2014 I can confirm the same problem. It works fine if the roles part of the selector is not included - all users are displayed and selection of one and saving the page works fine. Doesn't help you I know, but maybe helps to narrow down the problem As a workaround for now, use this in the custom PHP code option instead: return $pages->get("name=users")->children("roles=broker"); PS Do you feel like submitting an Issue on Github about this? 2 Link to comment Share on other sites More sharing options...
kongondo Posted November 26, 2014 Share Posted November 26, 2014 Related issues: https://processwire.com/talk/topic/4222-custom-field-to-select-unpublished-pages-selectable-but-doesnt-save-selection/ https://processwire.com/talk/topic/5083-possible-bug-page-fieldtype-with-custom-selector-to-find-selectable-pages-returns-error-while-saving-page/ From that last link, it says that you would have to use ID instead...('template=user, roles=1234')...See Ryan's explanation... 2 Link to comment Share on other sites More sharing options...
adrian Posted November 26, 2014 Share Posted November 26, 2014 Thanks kongondo - I had forgotten about that. Just to confirm - I tried your scenario @everfreecreative and it works perfectly with the role ID, eg: template=user, roles=1015 Link to comment Share on other sites More sharing options...
thetuningspoon Posted November 26, 2014 Author Share Posted November 26, 2014 Fantastic. Thanks guys! Link to comment Share on other sites More sharing options...
pjg Posted January 22, 2015 Share Posted January 22, 2015 Having trawled through the various options: use ID of roles Custom PHP utilising ->hasRole use path of role I can display a list of users defined by a role (in the above ways), for a Page field, but no matter what I try I always get a failed save. Am I missing something? Have I misread the documentation and can't assign Pages under the admin section to pages in the non-admin section? Any help would be appreciated as I'm completely stumped. EDIT: Currently running 2.5.3 EDIT2: Soma's test script returns valid for all of the users using the above methods, invalid when using the role name (as expected). EDIT 3: On further testing it transpires that the only way I seem to be able to add user pages to the page field is via the "parent of selectable pages" setting. All other settings cause an error similar to Error saving field "assigned" - Page 41 is not valid for assigned whether used in conjunction or as a stand-alone. Final Edit: Resolved - issue caused by ambiguous description (see screenshot). It turns out that the selector alone is sufficient to display the correct pages, but without selecting the appropriate parent the pages would not add. Could I therefore propose (should this be the intended behaviour) that the description of the custom selector is updated to reflect this? The current wording of "rather than" implies that the selector option overrides the previous two and can be used standalone. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now