CWA 2.0 is in alpha: try it, build with it, give feedback. APIs can still change between releases; see Releases.
Composables
Which Composable?
Which CWA composable to use for a layout, a display component, a form, an admin tab, an auth page or a utility.
Every composable the module provides is auto-imported. Pick one by what the file you are writing does.
Decision Table
| You are writing | Use | Notes |
|---|---|---|
A layout (app/app/cwa/layouts/) | useCwaLayout | Applies the admin's style classes to the layout's root |
A display component (app/app/cwa/components/<Name>/<Name>.vue) | useCwaComponent | Recommended. Add plugins for collections (withCollection()) and uploaded files (withFile()) |
| A display component that needs one file field without the plugin array | useCwaFileField | The standalone form of withFile() |
| A component that only binds a resource, with no plugins | useCwaResource | Low level. useCwaComponent wraps it |
| Numbered pagination for a collection | useCwaCollectionPagination | Returns the page numbers to show |
| A form (a Symfony Form component) | useCwaForm plus one useCwaFormInput per field | useCwaFormRepeated for a RepeatedType, useCwaFormCollection for a CollectionType |
An admin tab (app/app/cwa/components/<Name>/admin/) | useCwaResourceManagerTab | Required in every tab |
| A field in an admin tab | useCwaResourceModel | useCwaResourceUpload for a file field |
| HTML from the API, with working internal links | useHtmlContent | Also returns the v-cwa-html directive |
| A link to a resource's page | useCwaResourceRoute | withCollection() already returns it as resolveResourceLink |
| A sort, filter or search bound to the URL | useQueryBoundModel | |
| Your own API request that respects draft and published | useCwaResourceEndpoint | |
| A custom login, password reset or email verification page | useLogin, useForgotPassword, useResetPassword, useVerifyEmail, useResendVerifyEmail | The layer's own auth pages use these |
Anything else goes through useCwa(), the service the composables are built on.
useCwaCollectionResource is deprecated. Use useCwaComponent(props, [withCollection()]) instead.