Comments (4)
Currently the generate function is coded within the React component that drives the input:
netlify-cms-widgets/packages/widget-id/src/control.tsx
Lines 26 to 39 in 67ac5d4
I think it'd be good to extract it out into a util function & export it
from netlify-cms-widgets.
Hi @henrikwirth, thanks for opening this issue!
It looks like there's a 'prepublish' event we can hook into to generate a uuid for a field. I think this could potentially solve this issue:
https://www.netlifycms.org/docs/beta-features/#registering-to-cms-events
This repo is quite outdated so I'm hesitate to dive back in, if you want to take a crack at setting something up (a new widget, or an update to this one) I'm happy to assist with any issues you might run into!
from netlify-cms-widgets.
I think I might have found a way. There is a newRecord: true
on the data that is passed to the prePublish hook if the item is newly created/duplicated. If we check for that, we can trigger the generation of the ID right there instead of initially pre-populated.
from netlify-cms-widgets.
CMS.registerEventListener({
name: "preSave",
handler: ({ entry }) => {
const data = entry.get("data");
if (entry.get("newRecord")) {
return data.set("id", "test-1234");
}
},
});
Not sure how we would access the Control Object to generate the ID according to the props. Any idea?
from netlify-cms-widgets.
Related Issues (20)
- Inline widget HOT 14
- Re-order widget – i18n ? HOT 1
- Adding widget script hides existing relations in CMS HOT 2
- @ncwidgets/file-relation not working on self assignment HOT 2
- Using `Publish and create new` doesn't create a new ID HOT 9
- Need test + CI
- File location for relation widget HOT 13
- File Location Widget is broken HOT 2
- (file-relation) Support simple list (string only) HOT 1
- Last updated widget
- [netlify-cms] Add ncw-reorder HOT 2
- unselect an item from a parent optional field HOT 3
- hidden option for ncw-id widget HOT 3
- Display_fields accept one field only HOT 10
- file-relation update
- Form builder widget
- Is it possible to use id widget as js deliver sript?
- Data table widget
- S3 media library
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from netlify-cms-widgets.