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

Querying forms via API (Kql) #75

Open
Matoseb opened this issue Jul 24, 2024 · 3 comments
Open

Querying forms via API (Kql) #75

Matoseb opened this issue Jul 24, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@Matoseb
Copy link

Matoseb commented Jul 24, 2024

Hello I get this error while fetching the site page using Nuxt KQL x Headless Kirby.
The website has multilanguage.
Is the plugin compatible with this workflow?

 ERROR  Failed KQL query "site" (...) with status code 500:
 { status: 'error',
  message:
   'Kirby\\Cms\\Page::__construct(): Argument #1 ($props) must be of type array, tobimori\\DreamForm\\Models\\FormPage given, called in /home/clients/da920ca64b0714c4f7b6fbc7005a2892/sites/mywebsite.com/site/plugins/kql/src/Kql/Interceptor.php on line 254',
  code: 500,
  key: null,
  details: [] }
@tobimori tobimori added the type: bug 🐛 Something isn't working label Jul 24, 2024
@tobimori
Copy link
Owner

I always assumed it was compatible (minus the built-in snippets, of course) and the API mode was specifically to support custom forms in headless setups. I will take a look when I find time.

@Matoseb
Copy link
Author

Matoseb commented Aug 17, 2024

I tried to query the forms page directly using KQL. But this was pointless.
You may close this issue.

I always assumed it was compatible (minus the built-in snippets, of course) and the API mode was specifically to support custom forms in headless setups. I will take a look when I find time.

It is! I even query the HTMX inside my Vue/Nuxt App 😅 instead of using the API.
For anyone interested:

  1. Had a few CORS isssues along the way (I had to allow all the HTMX request headers in the preflight request) in the headless.cors config.
  2. I'm rendering a dedicated php template to send the htmx:
    ...
    
      // query https://cms.kirby.example/mypage?form=page%3A%2F%2F134567
      $uuid = get('form');
      if($uuid == null) {
        throw new Exception('"form" query is required');
      }
      $uuid = urldecode($uuid);
    
      snippet('dreamform/form', [
        'form' => page($uuid),
    
    ...

@tobimori
Copy link
Owner

I just noticed that using KQL is not really possible, since models are not supported yet (I made an issue for that in the past). If you'd like to use KQL, you'd have to write a custom method that queries all fields depending on the type. Maybe I can add a toKqlArray method or something in the future, I will keep this open as a reminder to investigate it at some point...

@tobimori tobimori changed the title Error in Headless mode Querying forms via API (Kql) Aug 17, 2024
@tobimori tobimori added enhancement New feature or request and removed type: bug 🐛 Something isn't working labels Aug 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants