Skelital gui list page
[civicrm-core.git] / ext / afform / docs / crud.md
CommitLineData
64423b13 1# Form CRUD: Updating forms via programmatic API
8a0ffdf9
TO
2
3Now that we've defined a baseline form, it's possible for administrators and
4GUI applications to inspect the form using the API:
5
6```
a00d9bd3 7$ cv api4 afform.get +w name=helloworld
8a0ffdf9 8{
a00d9bd3
TO
9 "0": {
10 "name": "helloworld",
11 "requires": [
12 "afformCore"
13 ],
14 "title": "",
15 "description": "",
16 "is_public": false,
17 "server_route": "civicrm/hello-world",
18 "layout": {
19 "#tag": "div",
20 "#children": [
21 "Hello {{routeParams.name}}"
22 ]
23 },
24 }
8a0ffdf9
TO
25}
26```
27
28Additionally, you can also update the forms:
29
30```
a00d9bd3 31$ cv api4 afform.update +w name=helloworld +v title="The Foo Bar Screen"
8a0ffdf9 32{
a00d9bd3 33 "0": {
8a0ffdf9
TO
34 "name": "helloworld",
35 "title": "The Foo Bar Screen"
36 }
37}
38```
39
40A few important things to note about this:
41
42* The changes made through the API are only applied on this site.
43* Once you make a change with the CRUD API, there will be two copies of the form:
44 * `[myextension]/afform/helloworld/` is the default, canonical version.
45 * `[civicrm.files]/afform/helloworld/` is the local, custom version.
46* The `layout` field is stored as an Angular-style HTML document (`layout.html`), so you can edit it on disk like
47 normal Angular code. However, when CRUD'ing the `layout` through the API, it is presented in JSON-style.