Skelital gui list page
[civicrm-core.git] / ext / afform / docs / crud.md
1 # Form CRUD: Updating forms via programmatic API
2
3 Now that we've defined a baseline form, it's possible for administrators and
4 GUI applications to inspect the form using the API:
5
6 ```
7 $ cv api4 afform.get +w name=helloworld
8 {
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 }
25 }
26 ```
27
28 Additionally, you can also update the forms:
29
30 ```
31 $ cv api4 afform.update +w name=helloworld +v title="The Foo Bar Screen"
32 {
33 "0": {
34 "name": "helloworld",
35 "title": "The Foo Bar Screen"
36 }
37 }
38 ```
39
40 A 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.