Jump to content
steveooo

Possible bug in Page inputfield?

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.

Share this post


Link to post
Share on other sites

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.

  • Like 2

Share this post


Link to post
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?

Share this post


Link to post
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!

Share this post


Link to post
Share on other sites
I don't see where you set:

$field->derefAsPage == FieldtypePage::derefAsPageOrNullPage;

When you don't set it it will store as a PageArray. 

  • Like 3

Share this post


Link to post
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!

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By AndZyk
      Hello,
      when you add a page you can see the page name of the page under the page title field. But when you change the page title afterwards, you have to go to the settings tab to also change the page name.
      We have many clients that change the page title afterwards but forget to change the page name, because they don't look in the settings tab or forget it.
      Is it possible to show the page name on the content tab under the page title?
      I hate to say this, but I like how WordPress handles this better:

      Or should I open an GitHub request?
      Regards, Andreas
    • By Gadgetto
      Hi,
      for my GroupMailer module I've created a custom Fieldtype + Inputfield module which provides multi-column field values. The first field column is a visible text field and there are some other columns which are not presented to user (they are rendered as hidden form fields).

      This is the database schema:
      $schema['data'] = 'text NOT NULL'; // we're using 'data' to represent our 'subject' field $schema['sendstatus'] = 'tinyint NOT NULL DEFAULT 0'; // message send status $schema['recipients'] = "int(10) unsigned NOT NULL DEFAULT 0"; // recipients counter $schema['sent'] = "int(10) unsigned NOT NULL DEFAULT 0"; // sent counter $schema['started'] = "int(10) unsigned NOT NULL DEFAULT 0"; // message sending start $schema['finished'] = "int(10) unsigned NOT NULL DEFAULT 0"; // message sending finished This are the ___wakeupValue and ___sleepValue methods:
      Now I try to extend this Fieldtype/Inputfield to provide multi language features.
      Only the first value ("data" which represents the "subject" field) should be/needs to be multi language!
      I had a look at the built in Fieldtypes (e.g FieldtypeText & FieldtypeTextLanguage) which provides multi language support but I couldn't find a similar case (multi-value field with language support). All built in Fieldtypes are single-value fields.
      I know this is a very "general" question but maybe somebody could push me in the right direction?
    • By Harmen
      I want to add a few pages to an AsmSelect Page field inside a repeater using the following code:
      $trialsPage = wire("pages")->get(28422); // Get the page $trialsPage->of(false); $newTrial = $ordersPage->trial_repeater_orders->getNewItem(); // Add item to repeater foreach ($selectedProducts as $selectedProduct){ $productPage = $pages->get("template=product, reference=$selectedProduct"); $newTrial->trial_selected_products->add($productPage); } $newTrial->save(); $trialsPage->save(); However, when I check the page where the field is located it doesn't have the new values as expected. The selected pages exist, the field is in the right location, made sure that the output formatting is turned off: $page->of(false); But it still doesn't work with a variable. No matter what I try, it doesn't work.
      It only works when I replace $selectedProduct with a hardcoded string. Am I doing something wrong here?
    • By Sebi2020
      Hey, I'm new and I created a simple module for tagging pages because I didn't found a module for it (sadly this is not a core feature). This module is licensed under the GPL3 and cames with absolutly no warranty at all. You should test the module before using it in production environments. Currently it's an alpha release. if you like the module or have ideas for improvements feel free to post a comment. Currently this fieldtype is only compatible with the Inputfield I've created to because I haven't found  an Inputfield yet, that returns arrays from a single html input.
      Greetings Sebi2020
      FieldtypeTags.zip.asc
      InputfieldTagify.zip
      InputfieldTagify.zip.asc
      FieldtypeTags.zip
    • By Robin S
      Pages At Bottom
      Keeps selected pages at the bottom of their siblings.
      A "bottom page" will stay at the bottom even if it is drag-sorted to a different location or another page is drag-sorted below it (after Page List is refreshed the bottom page will still be at the bottom).
      Newly added sibling pages will not appear below a bottom page.
      The module also prevents the API methods $pages->sort() and $pages->insertAfter() from affecting the position of bottom pages.
      Note: the module only works when the sort setting for children on the parent page/template is "Manual drag-n-drop".
      Why?
      Because you want some pages to always be at the bottom of their siblings for one reason or another. And someone requested it. 🙂
      Usage
      Install the Pages At Bottom module.
      Select one or more pages to keep at the bottom of their siblings. If you select more than one bottom page per parent then their sort order in the page list will be the same as the sort order in the module config.

       
      https://github.com/Toutouwai/PagesAtBottom
      https://modules.processwire.com/modules/pages-at-bottom/
×
×
  • Create New...