Coder Social home page Coder Social logo

Comments (4)

littleforest avatar littleforest commented on June 17, 2024

@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.

pablobm avatar pablobm commented on June 17, 2024

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.

littleforest avatar littleforest commented on June 17, 2024

@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.

pablobm avatar pablobm commented on June 17, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.