You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
// 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.
The text was updated successfully, but these errors were encountered:
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:
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.
The text was updated successfully, but these errors were encountered: