Skip to content

Commit 5693174

Browse files
authored
Merge pull request #10 from aposidelov/patch-1
Autoform Update mode section with example
2 parents 311a79d + 0307423 commit 5693174

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

README.md

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,10 @@ Posts.attachSchema(Schemas.Posts);
6262

6363
The `collection` property must be the same as name of your *FilesCollection* (*case-sensitive*), `Images` in our case.
6464

65-
- Generate the form with `{{> quickform}}` or `{{#autoform}}`
66-
e.g.:
65+
Generate the form with `{{> quickform}}` or `{{#autoform}}` e.g.:
66+
67+
##### Insert mode:
68+
6769
```html
6870
{{> quickForm collection="Posts" type="insert"}}
6971
<!-- OR -->
@@ -74,6 +76,22 @@ e.g.:
7476
{{/autoForm}}
7577
```
7678

79+
##### Update mode:
80+
81+
```html
82+
{{#if Template.subscriptionsReady }}
83+
{{> quickForm collection="Posts" type="update" doc=getPost}}
84+
{{/if}}
85+
<!-- OR -->
86+
{{#if Template.subscriptionsReady }}
87+
{{#autoForm collection="Posts" type="update" doc=getPost}}
88+
{{> afQuickField name="title"}}
89+
{{> afQuickField name="picture"}}
90+
<button type="submit" class="btn btn-primary">Update</button>
91+
{{/autoForm}}
92+
{{/if}}
93+
```
94+
Autoform should be wrapped in **{{#if Template.subscriptionsReady }}** which makes sure that template level subscription is ready. Without it the picture preview won't be shown. You can see update mode example [here](https://github.com/VeliovGroup/meteor-autoform-file/issues/9).
7795
### Multiple images //does not support yet
7896
If you want to use an array of images inside you have to define the autoform on on the [schema key](https://github.com/aldeed/meteor-simple-schema#schema-keys)
7997

0 commit comments

Comments
 (0)