Skip to content

Selector treated inconsistently between InputfieldPage and FieldtypePage for repeaters #479

@Toutouwai

Description

@Toutouwai

Short description of the issue

Take the following example selector string for selectable pages in a Page Reference field named 'pr_1':

pr_2=page.id

So the selectable pages for pr_1 consist of pages where the page being edited is selected in another Page Reference field, pr_2.

This works fine in most cases, but when pr_1 is inside a repeater the selector (and therefore the selectable pages) is evaluated differently in InputfieldPage than in FieldtypePage. When choosing pages that can appear in the inputfield, InputfieldPage treats the page portion of the selector as the page being edited (the page that contains the repeater field). But when the edited page is saved, FieldtypePage rejects the value of pr_1 because it treats page as the repeater page.

It's debatable which is more correct (page is the edited page or page is the repeater page - I'd prefer the former), but in any case there should be consistency in how the selector is treated.

Suggestion for a possible fix

FieldtypePage could convert the $page argument of sleepValue() to the edited page:

// borrowed from ProcessPageEditLink
$n = 0;
while(wireInstanceOf($page, 'RepeaterPage') && ++$n < 10) {
    /** @var RepeaterPage $page */
    $page = $page->getForPage();
}

Setup/Environment

  • ProcessWire version: 3.0.88

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions