Split README.md into smaller `docs/*.md` files
[civicrm-core.git] / ext / afform / docs / crud.md
CommitLineData
8a0ffdf9
TO
1## Development: Form CRUD API
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```
7$ cv api afform.getsingle name=helloworld
8{
9 "name": "helloworld",
10 "requires": [
11 "afformCore"
12 ],
13 "title": "",
14 "description": "",
15 "layout": {
16 "#tag": "div",
17 "#children": [
18 "Hello {{routeParams.name}}"
19 ]
20 },
21 "id": "helloworld"
22}
23```
24
25Additionally, you can also update the forms:
26
27```
28$ cv api afform.create name=helloworld title="The Foo Bar Screen"
29{
30 "is_error": 0,
31 "version": 3,
32 "count": 2,
33 "values": {
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.