steveooo Posted March 11, 2016 Share Posted March 11, 2016 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: 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 More sharing options...
nikosch Posted March 11, 2016 Share Posted March 11, 2016 Maybe you selected the wrong input field type? 1 Link to comment Share on other sites More sharing options...
steveooo Posted March 11, 2016 Author Share Posted March 11, 2016 No, sorry. Double checked that Link to comment Share on other sites More sharing options...
Soma Posted March 11, 2016 Share Posted March 11, 2016 If you only want to allow one page you should also configure to only allow single page. Currently you have a single select but the field is multiple. 2 Link to comment Share on other sites More sharing options...
steveooo Posted March 12, 2016 Author Share Posted March 12, 2016 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 More sharing options...
steveooo Posted March 14, 2016 Author Share Posted March 14, 2016 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 More sharing options...
Martijn Geerts Posted March 14, 2016 Share Posted March 14, 2016 I don't see where you set: $field->derefAsPage == FieldtypePage::derefAsPageOrNullPage; When you don't set it it will store as a PageArray. 3 Link to comment Share on other sites More sharing options...
steveooo Posted March 14, 2016 Author Share Posted March 14, 2016 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 More sharing options...
Martijn Geerts Posted March 14, 2016 Share Posted March 14, 2016 Not a bug, it just how it is. The 1 page is forced by the Inputfield, not the Fieldtype. 3 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now