Jump to content
Lance O.

Bug and possible cause: Page {ID} is not valid for {FIELD}

Recommended Posts

This is in response to the following posts:

https://processwire.com/talk/topic/5083-possible-bug-page-fieldtype-with-custom-selector-to-find-selectable-pages-returns-error-while-saving-page/

https://processwire.com/talk/topic/5683-inputfield-page-with-selector-rolesrole-page-1022-is-not-valid-for-field/

I am currently working on a site where I am using a Page field to assign multiple "products" to an individual "part". The "products" Page field stopped working recently and instead produces a "Page {ID} is not valid for {FIELD}" error. (Unfortunately, I'm not sure when it stopped working, but a design partner reported it to me today.)

I created a second Page field that used the exact same settings. The second Page field worked with no problems. When I exported both fields to compare them, I noticed that the original Page field had a parent_id of 1052 assigned to it. When I manually changed that parent_id to 0 to match the working Page field via phpMyAdmin, the original Page field started working correctly again.

Below are two exported fields. The first ("products") is the Page field that was giving me errors. The second ("products_test") is the test field I created that worked with no problems.

I looked in my database and did not find any record of 1052, so I can only assume that it must have been a page that was deleted at some point. If it was deleted, then perhaps that id value wasn't removed from the Page field at that time?

{
    "products": {
        "id": 147,
        "type": "FieldtypePage",
        "flags": 0,
        "name": "products",
        "label": "Products",
        "derefAsPage": 0,
        "parent_id": 1052,
        "labelFieldName": "title",
        "inputfield": "InputfieldAsmSelect",
        "findPagesCode": "return $pages->find(\"template=product,sort=title\");",
        "allowUnpub": "",
        "collapsed": 0,
        "showIf": "",
        "columnWidth": 100,
        "required": "",
        "requiredIf": "",
        "template_id": "",
        "findPagesSelector": "",
        "defaultValue": "",
        "addable": ""
    },

    "products_test": {
        "id": 172,
        "type": "FieldtypePage",
        "flags": 0,
        "name": "products_test",
        "label": "Products (TEST)",
        "derefAsPage": 0,
        "parent_id": 0,
        "findPagesCode": "return $pages->find(\"template=product,sort=title\");",
        "labelFieldName": "title",
        "inputfield": "InputfieldAsmSelect",
        "allowUnpub": "",
        "collapsed": 0,
        "showIf": "",
        "columnWidth": 100,
        "required": "",
        "requiredIf": "",
        "template_id": "",
        "findPagesSelector": "",
        "defaultValue": "",
        "addable": ""
    }
}

Share this post


Link to post
Share on other sites

For me this is throwing a more detailed error. But this still should not happen, as the php selection should override all the other selectionmodes.

"Session: Error saving field "page" - Page 1045 is not valid for page (Page 1045 does not have required parent 1044)"

P.S. I'm ultimately for not changing anything on field settings, because they are after all set up in any way for a reason.

Edit: Found the culprit in InputfieldPage.module

		if($field->findPagesCode) {
			// TODO: we don't currently validate these
		} 

		if($field->parent_id && $field->parent_id != $page->parent_id) {
			//Checks parent even though it shouldn't
		}

I'll open an issue over at GitHub.

Share this post


Link to post
Share on other sites

By chance, this same error just occurred on another site I am developing. Again, manually setting parent_id to 0 in the database fixed the problem.

Glad to see that you found the culprit. Looking forward to seeing a fix in the next release.  ;)

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 VeiJari
      Hello forum. I'm trying to figure out how to detect if current form has errors after saving it in pw admin page. This is so that our event location isn't added in database if we detect errors. But I can't seem to find a correct way to detect errors? I only found the wire()->errors() and it always triggers even if I don't have any errors. 
      How can I detect errors in a form?
      By error I mean $page->error('this is the red error');
    • By DevCat
      Hi,
      I'm trying to install ProcessWire on XAMPP localhost. I extracted the zip and put the files from master folder to website directory folder and when I go there with Firefox it says 404 page not found (no site configuration or install.php available). At least install.php surely is there. I'm doing WordPress installations on localhost almost every day and no problems. Does anyone here know what is cause for this error?
    • By Guy Incognito
      I added some custom styles to the CKeditor menu bar using the example mystyles.js and the PW tutorial. This worked fine for fields when editing on the frontend. But none of our custom styles showed in the backend editor dropdown unless we edited the core copy of mystyles.js in wire/modules.
      Is this correct behaviour, a bug or a mistake on my part? Tried clearing cache, logging in/out etc but the backend ignores our custom styles in the site/modules path.
    • By karian
      I don't know why multiple instances (repeater_repeat_columns1, repeater_repeat_columns2, ...) of my repeater field are displayed inside Template field (see image).
      Is there a way to clean/reset it ?
       

    • By sam-vital
      Hi,
      So I'm working on my site, getting round to completing it. I remember that I haven't checked at all what it will be like on other devices, so that's my next task.
      I went to the index page and I get hit with this error:
      Fatal error: Exception: SQLSTATE[HY000] [2002] Connection refused (in /var/sites/b/mysite.org/public_html/wire/core/ProcessWire.php line 377) #0 /var/sites/b/mysite.org/public_html/wire/core/ProcessWire.php(209): ProcessWire\ProcessWire->load(Object(ProcessWire\Config)) #1 /var/sites/b/mysite.org/public_html/index.php(52): ProcessWire\ProcessWire->__construct(Object(ProcessWire\Config)) #2 {main} in /var/sites/b/mysite.org/public_html/index.phpon line 64
      All I have done from the last code update was change a links target to blank, pushed the update and tested it. Now my site is broken? Went back and changed to the original file and I'm still getting the error.
      I really don't understand what has happened. I am an ok {6 months} web developer with this being my first experience of PW.
      All help is appreciated 🙂
×
×
  • Create New...