Jump to content

Possible bug in Page inputfield?


steveooo
 Share

Recommended Posts

Hello guys,

I have a Page field for my own global media gallery. When I select one page, I get following PageArray via the API:


object(ProcessWire\PageArray)#287 (7) {
  ["hooks"]=>
  array(2) {
    ["PageArray::render"]=>
    string(60) "MarkupPageArray->renderPageArray() in MarkupPageArray.module"
    ["PageArray::renderPager"]=>
    string(56) "MarkupPageArray->renderPager() in MarkupPageArray.module"
  }
  ["count"]=>
  int(3)
  ["items"]=>
  array(3) {
    [0]=>
    string(29) "/files/unpublished/"
    [1]=>
    string(25) "/files/animals/"
    [2]=>
    string(23) "/files/sloth/"
  }
  ["total"]=>
  int(3)
  ["start"]=>
  int(0)
  ["limit"]=>
  int(0)
  ["selectors"]=>
  string(0) ""
}

So I select 1 Page and get 3 Pages in return? How can this happen? From the interface here, everything looked fine:

post-2972-0-36590200-1457694522_thumb.pn

Here is the stuff that created the field (if needed):

$data['getFileField'] = new Field();
$data['getFileField']->type = $this->modules->get('FieldtypePage');
$data['getFileField']->name = 'fooBar';
$data['getFileField']->label = $this->_('File select');
$data['getFileField']->parent_id = $files['page']->id;
$data['getFileField']->inputfield = 'InputfieldPageListSelect';
$data['getFileField']->labelFieldName = 'title';
$data['getFileField']->allowUnpub = 1;
$data['getFileField']->description = $this->_('Select one file or folder. If folder is selected, the first file inside of it is used.');
$data['getFileField']->icon = 'file-o';
$data['getFileField']->save();

Is this a bug?

EDIT:

Now I am pretty sure it is a bug in PW (3.0.10):

If I select a page via the Page field, the PageArray is only with this page.

If I change the page via the Page field (and save), I get the old one plus the new one.

So somehow it does not get reseted on new selection.

Link to comment
Share on other sites

The thing is: Even if I allow the "folder" page that has children (files or another folder), the Page select would give me the children. But It somehow remembers the old selection and does only add to it. Maybe some caching thing even if I disabled all caching?

Any idea how I can test it better to find the bug?

EDIT:

When I select a single page with no children, the Page select also does not work...

The behavior is like this:

If I change my selection, the old one does not get removed. All previous selections still appear as items in the resulted PageArray.

This very seems like a bug. Does it help for you guys (and girls) when I upload a screencast of the bug?

Link to comment
Share on other sites

Hello guys,

hope you all had a great weekend!

I made a short screencast that shows the bug and its behavior. Maybe this helps anyone for a fix or for a solution (maybe I am doing something wrong?).

The bug is that it should have replaced the Sky-1.jpg item instead of only adding the new one.

Here is the video:

page-bug.mov

Thanks for your answers!

Link to comment
Share on other sites

Thank you! That was the problem!

But is it still a bug? I thought that using PageArray output for the Page field, I get (when only one page is selectable) a PageArray with only one item in it. Kind of return $page vs return array($page)..

But thanks again!

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...