processwire-issues icon indicating copy to clipboard operation
processwire-issues copied to clipboard

Overriding FieldtypePage/InputfieldPage->derefAsPage in template breaks field

Open mpsn opened this issue 2 years ago • 4 comments

Short description of the issue

Page Reference fields break completely when overriding derefAsPage from Multiple to Single.

The other way around, overriding from Single to Multiple, it doesnt let you save more than one reference.

Steps to reproduce the issue

  1. Create a field of type Page Reference with value type Multiple / PageArray (i am using Page Auto Complete as input method)
  2. Enable overriding value type (derefAsPage)
  3. Add field to template
  • a) 4. In the template settings, override derefAsPage to Single Page 5. Edit a page with the template, click save 6. Out of memory because infinite recursion
  • b) 4. Edit page and add some pages as field value, save page 5. In the template settings, override derefAsPage to Single Page 6. Try to edit the page again

Setup/Environment

ProcessWire version: 3.0.210

mpsn avatar Aug 09 '23 13:08 mpsn

Confirmed. I get error `Method Page::add does not exist or is not callable in this context (in /wire/core/Wire.php line 563) and I can't edit a page (The process returned no content.).

matjazpotocnik avatar Aug 09 '23 18:08 matjazpotocnik

Yeah, in theory there is some Is PageArray but should be Page in the value handling, but ultimately it seems neither wakeup/sleep conversion nor the override itself work as intended. So far i haven't tracked it down further.

mpsn avatar Aug 10 '23 12:08 mpsn

The override list shows all settings used by the field, but only those in bold are supported and known to work. Any others are YMMV... they might work or they might not (per the note in the Overrides tab). The derefAsPage is not a setting that is known to work, and I'm not sure it can be, but happy to look at it closer. But since we're trying to reduce the issues list here to just bugs, and this isn't a bug, maybe we should move this one to the feature requests list.

ryancramerdesign avatar Aug 10 '23 19:08 ryancramerdesign

If its just a matter of the value handling i'd be happy to help.

I'm not sure how (and where) the field configuration works. Are overrides uniformly applied on field object initialization?

mpsn avatar Aug 11 '23 09:08 mpsn