Skip to content

Commit 5ba7b57

Browse files
authored
Merge branch 'master' into docs/beta-features/widget-variable-types
2 parents 3f9e426 + a3939e0 commit 5ba7b57

3 files changed

Lines changed: 65 additions & 57 deletions

File tree

website/content/docs/beta-features.md

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -59,64 +59,7 @@ collections:
5959
The above config will transform the title field to uppercase and format the date field using `YYYY-MM-DD` format.
6060
Available transformations are `upper`, `lower`, `date('<format>')`, `default('defaultValue')`, `ternary('valueForTrue','valueForFalse')` and `truncate(<number>)`/`truncate(<number>, '<string>')`
6161

62-
## Registering to CMS Events
6362

64-
You can execute a function when a specific CMS event occurs.
65-
66-
Example usage:
67-
68-
```javascript
69-
CMS.registerEventListener({
70-
name: 'prePublish',
71-
handler: ({ author, entry }) => console.log(JSON.stringify({ author, data: entry.get('data') })),
72-
});
73-
```
74-
75-
Supported events are `prePublish`, `postPublish`, `preUnpublish`, `postUnpublish`, `preSave` and `postSave`. The `preSave` hook can be used to modify the entry data like so:
76-
77-
```javascript
78-
CMS.registerEventListener({
79-
name: 'preSave',
80-
handler: ({ entry }) => {
81-
return entry.get('data').set('title', 'new title');
82-
},
83-
});
84-
```
85-
86-
## Dynamic Default Values
87-
88-
When linking to `/admin/#/collections/posts/new` you can pass URL parameters to pre-populate an entry.
89-
90-
For example given the configuration:
91-
92-
```yaml
93-
collections:
94-
- name: posts
95-
label: Posts
96-
folder: content/posts
97-
create: true
98-
fields:
99-
- label: Title
100-
name: title
101-
widget: string
102-
- label: Object
103-
name: object
104-
widget: object
105-
fields:
106-
- label: Title
107-
name: title
108-
widget: string
109-
- label: body
110-
name: body
111-
widget: markdown
112-
```
113-
114-
clicking the following link: `/#/collections/posts/new?title=first&object.title=second&body=%23%20content`
115-
116-
will open the editor for a new post with the `title` field populated with `first`, the nested `object.title` field
117-
with `second` and the markdown `body` field with `# content`.
118-
119-
**Note:** URL Encoding might be required for certain values (e.g. in the previous example the value for `body` is URL encoded).
12063

12164

12265
## Remark plugins
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
title: Dynamic Default Values
3+
group: Fields
4+
weight: 30
5+
---
6+
7+
When linking to `/admin/#/collections/posts/new` you can pass URL parameters to pre-populate an entry.
8+
9+
For example given the configuration:
10+
11+
```yaml
12+
collections:
13+
- name: posts
14+
label: Posts
15+
folder: content/posts
16+
create: true
17+
fields:
18+
- label: Title
19+
name: title
20+
widget: string
21+
- label: Object
22+
name: object
23+
widget: object
24+
fields:
25+
- label: Title
26+
name: title
27+
widget: string
28+
- label: body
29+
name: body
30+
widget: markdown
31+
```
32+
33+
clicking the following link: `/#/collections/posts/new?title=first&object.title=second&body=%23%20content`
34+
35+
will open the editor for a new post with the `title` field populated with `first`, the nested `object.title` field
36+
with `second` and the markdown `body` field with `# content`.
37+
38+
**Note:** URL Encoding might be required for certain values (e.g. in the previous example the value for `body` is URL encoded).
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
title: Registering to CMS Events
3+
weight: 80
4+
group: Customization
5+
---
6+
7+
You can execute a function when a specific CMS event occurs.
8+
9+
Example usage:
10+
11+
```javascript
12+
CMS.registerEventListener({
13+
name: 'prePublish',
14+
handler: ({ author, entry }) => console.log(JSON.stringify({ author, data: entry.get('data') })),
15+
});
16+
```
17+
18+
Supported events are `prePublish`, `postPublish`, `preUnpublish`, `postUnpublish`, `preSave` and `postSave`. The `preSave` hook can be used to modify the entry data like so:
19+
20+
```javascript
21+
CMS.registerEventListener({
22+
name: 'preSave',
23+
handler: ({ entry }) => {
24+
return entry.get('data').set('title', 'new title');
25+
},
26+
});
27+
```

0 commit comments

Comments
 (0)