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

[4.1] Add hint to FetchOperation in documentation for InlineCreate operation / 'relationship' field type #144

Open
cplewnia opened this issue May 22, 2020 · 0 comments
Labels

Comments

@cplewnia
Copy link
Contributor

cplewnia commented May 22, 2020

Background

I implemented a relationship field for a Category attribute within a Product's CRUD controller. I followed the InlineCreate Operation documentation.

I expected to be able to see existing category entities in the relationship and be able to search for existing category entities. Both things did not work. The category field just stayed empty.

The browser's developer console showed me error 404s for the fetch-routes. For example, when opening the product's create/update view, the category field did not show any content, but the browser reported an error 404 for /admin/product/fetch/category (and more 404s when I continued to type in the category field's search).

The solution

I stumbled upon the fact that I needed to implement the fetch operation (which enables ajax) in my CRUD controller as documented here.

The only hint is given by the code example on InlineCreate Operation documentation page:

// for 1-n relationships (ex: category) - inside ArticleCrudController
[
    'type' => "relationship",
    'name' => 'category', // the method on your model that defines the relationship
    'ajax' => true,
    'inline_create' => true, // assumes the URL will be "/admin/category/inline/create"
]

It shows the usage of 'ajax' => true. I at first thought it was just a coincidence of this example and that I can use the InlineCreate operation without ajax as neither the requirements nor the how to use sections document the requirement to implement the fetch operation / ajax.

I suggest to improve the documentation of the InlineCreate operation.

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

1 participant