-
Notifications
You must be signed in to change notification settings - Fork 2
Page Reference Field selector string issues #584
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
…InputfieldPageAutocomplete selectors
Thanks. For item 1, I've added your suggested fix. For item 2, I think this is because ProcessPageSearch is what's generating the results, and it may require a little bit different syntax in this case, or we may need to update that module to support something here. What type of field are you trying to match? One thing you can try is |
Thanks. It looks like Do you think it's possible to use hook to filter the results somehow? That would by the best. |
This all passes through user input to ProcessPageSearch, so there are some limitations on the selector. It's rarely an issue because most use autocomplete for regular text searches. But for your case, I think you are right that a hook might be handy here. But I couldn't find an existing one that would be ideal, so I went ahead and added one. I've added a new hook
|
Thank you very much for making this hook. But for some reason the custom selector value I want to replace is not passing to the hook event. If I test the Edit:Actually, I thought I could use some random word as field name for replacement, but found out it needs to be a name of existing field, otherwise it won't pass (sanitizer?). So now it works! Also |
That's true that it's got to be a field name that PW recognizes, otherwise it ignores it. But you should be able to use |
Yes, it works. Sorry, my bad… The reason why |
The keywords "today" and "now" are both recognized by |
@ryancramerdesign When trying to save a page I'm getting an error: Session: Error saving field "slideshow" - Page 16571 is not valid for slideshow (Page 16571 does not match findPagesSelector: title=selectorHookReplace, id=16571) Expected behaviorPages on save should be matched against hooked (replaced) selector, not the replacement selector inside selector string. |
@fijha Hello, can you let us know if this is still an issue with more recent versions of PW? |
Yes, I tested in the most recent version (3.0.126)… the issue still exist. Ryan's solution works, but the page cannot be saved (as I mentioned in my previous comment), and because of that it's unfortunately unusable. |
@fijha It looks like you have the string |
Thanks Ryan. This could be a solution, but wondering if it can cause some other problems. How can I make sure it affects only one field I want and not interfere with other fields? Because to my understanding the hook affects all |
@fijha The requirement is that it just has to be a valid selector that will match. This is pretty easy to do with the id property because your front-end non-system page IDs start at 1000. So you could put it any |
Yes, I understand it has to be a valid selector, but my point is what if I have 2 or more (same type) fields that needs to use Or just for the sake of example, if I will use So It could lead to "bugs". Or would it be possible to check within a hook the field name or template of the page I'm editing? |
You wouldn't want to use |
I totally get it. But, I mean, it's not super safe. There must be a better (less hacky) way. Should I keep this issue open or maybe put it in the feature requests? Would it require o lot of time and work to just make it possible to use more complex selectors with Page Reference Field, e.g. match blank |
You should be able to use this sort of approach (i.e. insert some recognizable string that is unlikely to occur in a real search and check for it in your hook) - you just need to use a != operator so that this condition doesn't actually exclude any pages. |
@Toutouwai I'm not sure why I didn't think about that. Thank you very much! |
@fijha Actually it is super safe. The core even uses a similar technique when it needs to produce a non-empty selector that doesn't change the results. Since you are trying to hook into and change the way a page field selector validates results, it's going to be a hack either way, so I'd suggest this solution is a good way to do that. What @Toutouwai is also fine, though if your selector will ever be hitting the database unmodified I'd suggest sticking with using the id, as it won't add overhead whereas the field!=string solution could. |
@fijha Does Ryan's reply above allow you to close this issue now? |
@netcarver set a reminder for Nov 10th 2019 |
👋 @netcarver, review this issue |
@fijha I'm closing this issue now. If you need it reopened, just post again here. |
Short description of the issue
When using quotes inside Selector string with input field type Page Auto Complete, the admin page using this field break because its not properly escaped inside HTML
data-url
attribute.Another issue is that checking if field is empty (
field=''
orfield=
) doesn't work either.Suggestion for a possible fix
But checking if field is empty (
field=''
orfield=
) still doesn't work…Setup/Environment
The text was updated successfully, but these errors were encountered: