Comments (4)
@pablobm I feel like this behavior is actually correct. For a boolean checkbox, there is no way for the app to know whether you intend to leave the field as nil
or mark it as false
. Since it is a boolean field, I think it is okay that we assume it will be either true
or false
. I think the user should use Field::Select
if they want three options for the boolean.
from administrate.
Yeah, you may be right 🤔 My concern is that this may change data silently, without the knowledge of the admins.
For example: an app adds a "legal consent" boolean on users, but it's initially NULL to signify that the user hasn't answered the question yet. Then admins could be setting this to false
unintentionally when they edit users.
Theoretically, this could be addressed by leaving NULLs unchanged, and only allow the transitions NULL-true, true-false, false-true... but then what if the admin actually wants to transition NULL-false.
I guess it's on the admins to know that a Boolean is not correct thing to use. It still worries me, as I think its an easy mistake to make.
Thoughts? Happy to close if you think it's indeed on the admins to know. I guess at the very least we should mention it in the documentation. But who reads that! 😛
from administrate.
@pablobm maybe this is too complicated, but what if the boolean field defaults to a select with options [nil
, true
, false
], and we could have an allow_nil:
option on the BooleanField. If the user sets allow_nil: false
, then it just displays the current checkbox field.
Otherwise I don't think there's really a way for a user to specify the NULL-false transition as you noted, and we would probably just have to beef up the documentation to point this out.
from administrate.
Closing this. I think it's on admins to know, and adding it to the documentation is neither obvious nor effective (I can't imagine anyone reading it!).
from administrate.
Related Issues (20)
- Destroy button sending GET request instead of Delete. HOT 7
- Pundit error: not allowed to index? this Class HOT 1
- Example app: don't use float types for money HOT 3
- Exception: ActionView::Template::Error: uninitialized constant for multi-word model dashboard with irregular inflection HOT 1
- I changed the name of my controller and it broke administrate HOT 1
- Automated Basic Tests HOT 1
- View generators generates files with incorrect path HOT 2
- Tested with rails7 HOT 1
- Search truncates text fields silently HOT 2
- demo page doesnt work HOT 1
- Is this abandonware? HOT 1
- Add Impersonate integration with devise HOT 2
- libsass.so: cannot open shared object file with dartsass-rails and Rails 7.1 HOT 3
- DEPRECATION WARNING: The method `valid_action?` is deprecated HOT 1
- Enum field: undefined method `roles' for User:Class HOT 2
- Scope select options to a particular resource?
- Error when excluding asset paths in application.rb
- Sorting on "virtual" column
- Enum issues in Rails 7.1.2 and Ruby 3.2.1 HOT 1
- Model Field Not Picked Up HOT 1
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 administrate.