-
Notifications
You must be signed in to change notification settings - Fork 5
/
copy-field-data.html
41 lines (37 loc) · 1.38 KB
/
copy-field-data.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<!doctype html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<script src="https://unpkg.com/@contentstack/ui-extensions-sdk@2.2.0/dist/ui-extension-sdk.js"></script>
<link href="https://www.contentstack.com/sdks/contentstack-ui-extensions/dist/latest/ui-extension-sdk.css"
rel="stylesheet" type="text/css" media="all">
</head>
<body>
<div>
<div class="cs-checkbox">
<label style="margin:10px">
<input type="checkbox" class="cs" onchange="HandleChange(this)">
<span class="lbl"></span>
</label>
</div>
</div>
<script>
// initialise Field Extension
window.extensionField = {};
ContentstackUIExtension.init().then(function (extension) {
// make extension object globally available
extensionField = extension;
extensionField.window.updateHeight();
})
function HandleChange(checkbox) {
if (checkbox.checked == true) {
var fromFieldData = extensionField.entry._changedData[extensionField.fieldConfig.from];
var toField = extensionField.entry.getField(extensionField.fieldConfig.to);
toField.setData(fromFieldData)
} else {
// uncheck functionality
}
}
</script>
</body>
</html>