[v0.3] Boolean fields with noedit:false and hidden:true do not retain value
See original GitHub issueExpected behavior
If a hidden yet editable boolean field has a true
value in the database, it should retain it when it’s saved through the admin UI.
Actual behavior
The field will always be set to false
, even if it were true
before
Steps to reproduce the behavior
1/ Add a Boolean field to a list
completed: {
type: Boolean,
default: false,
noedit: false,
hidden: true
}
2/ add a pre(‘save’) hook that will set it to true
if it’s not:
keystone.list('MyList').schema.pre('save', function(done){
if(!this.completed){
console.log('SETTING IT TO TRUE');
this.completed = true;
}
done();
});
Re-saving the document in the admin UI will output 'SETTING IT TO TRUE'
every time.
Motivation
This is useful for allowing documents that are constructed over time. I have several lists that allow people to come back and modify the document until a certain condition is met in which case further modification should no longer be allowed.
Issue Analytics
- State:
- Created 7 years ago
- Comments:16 (12 by maintainers)
Top Results From Across the Web
2615810 - Boolean field not retaining values - yesNo / trueFalse
Boolean or yes/no fields are not working properly. The value is not persisted and sometimes the dropdown leads to application error.
Read more >keystone/HISTORY.md at master - GitHub
v0.3.20 / 2016-06-17. fixed; Boolean fields with noedit:false and hidden:true do not retain value; fixed; Default formatString for Datetime ...
Read more >Hidden Boolean Field Set As True - Not Working
I am working on a compliance program where everyone will run through a double-opt-in ... Any reason why this hidden boolean value is...
Read more >Why is my hidden input writing: value="value" instead of true ...
The form field is posting to an input parameter of the form: public ActionResult SomeAction(bool somefield = false, ...).
Read more >Can a Geopackage Boolean field contain a NULL value?
By the GeoPackage standard the Boolean values are stored as zero or one: A boolean value representing true or false.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Since the Admin UI is all react talking to an API we can submit a value now - it’s not a problem (for us) anymore. 0.3 actually submits an HTML
<form>
.Legacy use of the UpdateHandler would break with the change I’m proposing but we can work out a way around that. I’ll open another issue for discussion when I’m ready.
The
hidden
option wasn’t really intended for security, as such… but you’re right, it doesn’t mean others may not use it as one 😃Given our focus on 0.4 and that whatever the fix is won’t come forward anyway, I’m just going to hack a fix for this (for boolean fields specifically) into 0.3 now