docs - Update to reflect new naming convention. General copy-editing.
[civicrm-core.git] / ext / afform / docs / embed.md
index 4be406dfe921d9640ca6869ae64eb5e0d380fd49..e1ac30d5cae5ffc5473b437f61f501f5a02d013f 100644 (file)
@@ -1,23 +1,23 @@
 # Embedding Forms: Afform as reusable building-block
 
 In the [quick-start example](quickstart.md), we registered a new route (`"server_route": "civicrm/hello-world"`) -- this created a
-simple, standalone page with the sole purpose of displaying the `helloworld` form.  What if we want to embed the form
+simple, standalone page with the sole purpose of displaying the `helloWorld` form.  What if we want to embed the form
 somewhere else -- e.g. as a dialog inside an event-listing or membership directory?  Afforms are actually *re-usable
 sub-forms*.
 
-How does this work?  Every `afform` is an *AngularJS directive*.  For example, `helloworld` can be embedded with:
+How does this work?  Every `afform` is an *AngularJS directive*.  For example, `hello-world` can be embedded with:
 
 ```html
-<div afform-helloworld=""></div>
+<div hello-world=""></div>
 ```
 
-Moreover, you can pass options to `helloworld`:
+Moreover, you can pass options to `helloWorld`:
 
 ```html
-<div afform-helloworld="{phaseOfMoon: 'waxing'}"></div>
+<div hello-world="{phaseOfMoon: 'waxing'}"></div>
 ```
 
-Now, in `afform/helloworld/layout.html`, you can use `options.phaseOfMoon`:
+Now, in `ang/helloWorld.aff.html`, you can use `options.phaseOfMoon`:
 
 ```html
 Hello, {{routeParams.name}}. The moon is currently {{options.phaseOfMoon}}.
@@ -29,11 +29,11 @@ Is this useful? Let's suppose you're building a contact record page.
 
 First, we should make a few building-blocks:
 
-1. `afform/contactName/layout.html` displays a sub-form for editing first name, lastname, prefix, suffix, etc.
-2. `afform/contactAddressess/layout.html` displays a sub-form for editing street addresses.
-3. `afform/contactEmails/layout.html` displays a sub-form for editing email addresses.
+1. `ang/afformContactName.aff.html` displays a sub-form for editing first name, lastname, prefix, suffix, etc.
+2. `ang/afformContactAddresses.aff.html` displays a sub-form for editing street addresses.
+3. `ang/afformContactEmails.aff.html` displays a sub-form for editing email addresses.
 
-Next, we should create an overall `afform/contact/layout.html` which uses these building-blocks:
+Next, we should create an overall `ang/afformContact.aff.html` which uses these building-blocks:
 
 ```html
 <div ng-form="contactForm">
@@ -49,7 +49,7 @@ Next, we should create an overall `afform/contact/layout.html` which uses these
 </div>
 ```
 
-And we should create a `afform/contact/meta.json` looking like
+And we should create a `ang/afformContact.aff.json` looking like
 
 ```json
 {
@@ -57,8 +57,20 @@ And we should create a `afform/contact/meta.json` looking like
   "requires" : ["afformContactName", "afformContactEmails", "afformContactAddresses"]
 }
 ```
-> *(FIXME: In the parent form's `meta.json`, we need to manually add `afformContactName`, `afformContactAddresses`, `afformContactEmails` to the `requires` list. We should autodetect these instead.)*
+> *(FIXME: In the parent form's `*.aff.json`, we need to manually add `afformContactName`, `afformContactAddresses`, `afformContactEmails` to the `requires` list. We should autodetect these instead.)*
 
-What does this buy us?  It means that a downstream admin (using APIs/GUIs) can fork `afform/contactName/layout.html` --
+We've created new files, so we'll need to flush the file-index
+
+```
+cv flush
+```
+
+and now we can open the page
+
+```
+cv open 'civicrm/contact?cid=100'
+```
+
+What does this buy us?  It means that a downstream admin (using APIs/GUIs) can fork `ang/afformContactName.aff.html` --
 but all the other components can cleanly track the canonical release. This significantly reduces the costs and risks
 of manging upgrades and changes.