From 1e03a3c1bc9308d40397b28a2b4c0bb250a4ccc7 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Tue, 12 Jun 2018 18:48:20 -0700 Subject: [PATCH] README.md - Example dev tasks --- ext/afform/README.md | 56 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 54 insertions(+), 2 deletions(-) diff --git a/ext/afform/README.md b/ext/afform/README.md index bd0e854163..4e95873a00 100644 --- a/ext/afform/README.md +++ b/ext/afform/README.md @@ -35,9 +35,61 @@ git clone https://github.com/FIXME/org.civicrm.afform.git cv en afform ``` -## Usage +## Usage (Developers): Create a form -(* FIXME: Where would a new user navigate to get started? What changes would they see? *) +As an upstream publisher of a form, you can define the default, canonical +substance of the form by creating a folder named `afform/`. In +this example, we create a form named `foobar`: + +``` +$ cd /path/to/my/own/extension +$ mkdir -p afform/foobar +$ echo '{"route": "civicrm/foobar"}' > afform/foobar/meta.json +$ echo '
Hello {{param.name}}
' > afform/foobar/layout.html +$ cv flush +$ cv url civicrm/foobar?name=world +``` + +You can open the given URL in a web-browser. + +## Usage (Developers): Programmatically read and write forms + +Downstream, administrators may customize the form. + +``` +$ cv api afform.getsingle name=foobar +{ + "name": "foobar", + "requires": [ + "afform", + "crmUi", + "crmUtil" + ], + "title": "", + "description": "", + "layout": { + "#tag": "div", + "#children": [ + "Hello {{param.name}}" + ] + }, + "id": "foobar" +} +$ cv api afform.create name=foobar title="The Foo Bar Screen" +{ + "is_error": 0, + "version": 3, + "count": 2, + "values": { + "name": "foobar", + "title": "The Foo Bar Screen" + } +} +``` + +## Usage (Developers): Render a form + +(* FIXME *) ## Known Issues -- 2.25.1