Description
Short description of the issue
Page Reference fields behave in an unusual way when they contain a page that has been trashed. Take the following scenario...
In my home template I have two Page Reference fields, "test_page_single" and "test_page_multiple". In each of these fields I add the same "To trash" page (and only that page).
I then trash the "To trash" page. Now when I edit the Home page these fields appear to be empty.
But in the fields' tables in the database the value is retained. And I can save the Home page with these fields in their apparently empty state but still the trashed page is retained. This makes it impossible to remove the trashed page as a value and save these fields in a genuinely empty state. It is also potentially misleading as there is no way to tell the difference between an empty field and one that actually contains a trashed page.
When I get the value of these fields via the API they behave as if they are empty.
However, I cannot match the Home page in a selector that you would expect to work if these fields were empty.
I find this counter-intuitive. And if you are wanting to find both pages where the field is empty and appears to be empty due to containing a trashed page, what selector can you use for this?
So it's difficult to identify pages that are in this situation both via the admin interface and via the API, which can lead to a lot of head-scratching and time spent trying to work out what's going on.
I'm not sure what a good solution would be. It would be desirable if Page Reference fields containing trashed pages responded the same way as when they contain a page that is permanently deleted, but on the other hand I can imagine scenarios where a user trashes a page in error and you want to later restore it and retain the references to it. Does anyone have any ideas on how we could have the best of both worlds?
Setup/Environment
- ProcessWire version: 3.0.105