Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[1.2.1] "Fetch failed" error when updating parents field #1403

Closed
tomzmtl opened this issue Apr 4, 2017 · 5 comments
Closed

[1.2.1] "Fetch failed" error when updating parents field #1403

tomzmtl opened this issue Apr 4, 2017 · 5 comments
Assignees
Labels

Comments

@tomzmtl
Copy link

tomzmtl commented Apr 4, 2017

[UPDATE]: Though the error message doesn't show up on 1.1.17, there is still an issue where the page parent field value is always reset to "Root", which upon saving the page puts it back in the root scope, breaking the hierachy.

NOTE: this occurs on 1.2.0 after upgrading through the admin plugin.
I confirmed that reverting to 1.1.17 makes it work as expected.

I'm working on custom pages which all contain a copy of the following in their blueprint:

options:
  type: tab
  title: Options

  fields:
    header.title:
      type: text
      label: Page title
    route:
      type: select
      label: PLUGIN_ADMIN.PARENT
      classes: fancy
      '@data-options': '\Grav\Common\Page\Pages::parents'
      '@data-default': '\Grav\Plugin\admin::route'
      options:
        '/': PLUGIN_ADMIN.DEFAULT_OPTION_ROOT
    folder:
      type: text
      label: PLUGIN_ADMIN.FOLDER_NAME
      validate:
        rule: slug

Now, again using the admin plugin, I do the following:

  1. click on create page.
  2. select a specific page as parent page (must not be "Root").
  3. New page draft opens.
  4. Edit content, save.
  5. Observation: The page is now at its right place in the page hierarchy.
  6. Click on the page to edit.
  7. Observation: the parent selector is set back to "Root"
  8. Changing the parent in the selector yields the following error:
Fetch Failed: 
Cannot read property 'setValue' of undefined
TypeError: Cannot read property 'setValue' of undefined
at http://localhost/ordering-web-app-showcase/user/plugins/admin/themes/grav/js/admin.min.js?adad54c612:5:14356
at http://localhost/ordering-web-app-showcase/user/plugins/admin/themes/grav/js/admin.min.js?adad54c612:4:24902

Please let me know if more information is required, I'll be happy to help.

@flaviocopes
Copy link
Contributor

The default page blueprint uses

                    route:
                      type: select
                      label: PLUGIN_ADMIN.PARENT
                      classes: fancy
                      data-options@: '\Grav\Common\Page\Pages::parentsRawRoutes'
                      data-default@: '\Grav\Plugin\Admin\Admin::rawRoute'
                      options:
                        '/': PLUGIN_ADMIN.DEFAULT_OPTION_ROOT

so that might be why it's not getting populated with the right value on the second save. Can you check?

@tomzmtl
Copy link
Author

tomzmtl commented Apr 5, 2017

[UPDATE] Didn't work completely.

@flaviocopes Ok! Thanks for the tip. So that change fixed the default selection in the field, but I'm still getting the "Fetch failed" error whenever I try to change its value.

I know it may not be the right place for that question, but is there a way to reference that field from the core blueprints inside a custom blueprint, instead of copy/pasting it, to make it more future-proof?

@flaviocopes
Copy link
Contributor

"Fetch failed" is a generic issue that can appear when a network connection is failing, or is halted before it's complete. If you continue getting it, you can check the Browser's developer tools and see which request is failing, and possibly get a more detailed error message.

The import@ should be what you look after: https://learn.getgrav.org/forms/blueprints/advanced-features#embedding-form-import

@tomzmtl
Copy link
Author

tomzmtl commented Apr 11, 2017

Update on the issue:

  • I updated Grav + Admin to latest versions (1.2.1 and 1.3.2 respectively)
  • I updated my blueprint to use the new parents field:
route:
  type: parents
  label: PLUGIN_ADMIN.PARENT
  classes: fancy

After these changes, the issue still occurs.

Here's the only call showing up in my network calls upon field update:
screen shot 2017-04-11 at 2 24 23 pm

As you can see, there are no actual failure in the call.

Request payload:

------WebKitFormBoundaryzlF2is3cGEVccFJ7
Content-Disposition: form-data; name="admin-nonce"

93223a1d8360d0fdc4c2f030b44bd308
------WebKitFormBoundaryzlF2is3cGEVccFJ7
Content-Disposition: form-data; name="rawroute"

/privacy-policy
------WebKitFormBoundaryzlF2is3cGEVccFJ7--

Response:

child_type: "default"
status: "success"

What ends up in the console (unchanged since original issue):

admin.min.js?2e9c58283f:4 Cannot read property 'setValue' of undefined at TypeError: Cannot read property 'setValue' of undefined
    at https://gololocalhost-showcase.com/user/plugins/admin/themes/grav/js/admin.min.js?2e9c58283f:5:14356
    at https://gololocalhost-showcase.com/user/plugins/admin/themes/grav/js/admin.min.js?2e9c58283f:4:24902

@tomzmtl tomzmtl changed the title [1.2.0] "Fetch failed" error when changing parent page [1.2.1] "Fetch failed" error when changing parent page Apr 11, 2017
@tomzmtl tomzmtl changed the title [1.2.1] "Fetch failed" error when changing parent page [1.2.1] "Fetch failed" error when updating parents field Apr 11, 2017
@rhukster
Copy link
Member

In Admin 1.3.2, I did modify this task:getChildTypes task to return default rather than throwing an error if no child types is set. The problem is that this task is called in forms where there is a parent AND a template field. It's trying to set the field which does not exist in your blueprint, hence the error.

I think the fix is to not calls this ajax/update unless that field exists. @flaviocopes, @w00fz ??

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants