Comments (11)
For the variable object types, you can add only one field. Actually in your case, you can just use required: false
with widget: object
instead of variable types:
fields:
- label: 'Is it News?'
name: 'isNews'
required: false
widget: object
fields:
- label: 'News Description'
name: 'carousel'
widget: string
fields:
- {label: News Description, name: newsDescription, widget: string, required: false}
The UI will look like:
This cannot be done with Netlify/Decap CMS π
from sveltia-cms.
oh, this is much better, thanks!
from sveltia-cms.
I think the Decap Relation widget doc mentions the multiple
option π The checkbox UI is only with Sveltia π
I just shipped v0.26.2 to use a checkbox for optional (required: false
) objects. Iβll work on conditional fields sometime later.
from sveltia-cms.
I care a lot about the client's UX, and you make me happy! thanks!
this is better now than I expected!
from sveltia-cms.
I think this is relevant:
Sveltia CMS has already solved this problem by supporting variable types for the Object widget, not only for the List widget. I donβt have a detailed document yet, but you can use the same types
option to have conditional fields. Check it out!
from sveltia-cms.
Yes, I'm familiar with this, I'm using this feature already for other collections. You are right, that this is already working from another way. I just thought the boolean + condition field would be a more intuitive solution for this particular case when I need a clear on-off state. this is the solution with the variable types. I just need to inform the client not to generate more than one news field and the problem is solved.
fields:
- label: 'Is it News?'
name: 'isNews'
required: false
widget: 'list'
types:
- label: 'News Description'
name: 'carousel'
widget: string
fields:
- {label: News Description, name: newsDescription, widget: string, required: false}
Recording.2024-05-10.095642.mp4
from sveltia-cms.
And yeah, as you said, a checkbox may be more intuitive here. I can change the UI π
from sveltia-cms.
yes, but if it's only not hard to implement for you.
I guess it could be simple ternary operator to the string widget and could look like:
fields:
- label: Is it News?
name: isNews
widget: boolean <- or checkbox
default: true
required: false}
- label: News Description
name: newsDescription
visibleIf: 'isNews' <- maybe like this, or name it displayCondition?
widget: string}
from sveltia-cms.
wait, you mentioned checkboxes, are checkboxes possible for relation widget?
I went to the sveltia and decapcms issues and found only mention custom tag widget that is not supported at sveltia. I made that the client can build and modify categories list through reference content collection schema, and at current I can only let to select only one item through radio buttons. If it's possible to convert this field to checkboxes to get the array, please give me a hint.
fields:
- {label: Category, name: category, widget: relation, collection: categories, value_field: defaultLocaleVersion, display_fields: [category]}
from sveltia-cms.
You can get checkboxes with widget: relation
+ multiple: true
.
from sveltia-cms.
hehe, lol, that's unexpected:
it works like a charm!
I double checked now, and I still didn't find about "multiple: true" in the sveltiacms or decap readme.
You need proper documentation about advanced fields. :)
I will collect these cool options that I will find and prepare these for the template, 100% sure very few people know about these powerful options.
from sveltia-cms.
Related Issues (20)
- Feature Request: Multifile configurations HOT 1
- local development not working after recent update HOT 4
- Regression in fields with multiple values HOT 2
- `createCommitOnBranch` is null from GitHub GraphQL API HOT 4
- Cannot Login: Authentication aborted HOT 2
- YAML: support '<<' (merge key) HOT 3
- JavaScript error on save HOT 3
- Console error introduced in @sveltia/cms > 0.21.0 HOT 2
- PKCE authentication: content is not loaded and no error at all HOT 17
- Translated slugs between locales - linked translations via a reference property. Website with localized URL. HOT 23
- Set the maximum length of a text field HOT 6
- Migration Issue - There was an error while loading site data. - Unexpected Error HOT 5
- Write local timezone in dates when picker_utc = false HOT 4
- Follow field ordering of config when writing files HOT 2
- CMS on mount, not respecting localstorage HOT 3
- Multiple Files JSON File Structure - Localized File Collections HOT 15
- Dividers jump to another position when I change current collection HOT 6
- The backup popup bug HOT 5
- how to insert images inside the markdown
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 sveltia-cms.