Log message #4053115

# At Username Text
# Jul 17th 2017, 19:04 gglow thx
# Jul 17th 2017, 19:04 hmic +1
# Jul 17th 2017, 19:04 gglow -1,0,1 was my initial thought so must be the simplest
# Jul 17th 2017, 19:04 phantomwatson Yeah, I'd go with using -1, 0, and 1, personally. Though you could use a custom accessor to recast it to true, false, and null if there's some appeal to doing that.
# Jul 17th 2017, 19:04 gglow I'll use the integer, with a bit array/ contants
# Jul 17th 2017, 19:03 gglow also, if the value is false and needs to be changed to null, that would be an issue as it would need to save
# Jul 17th 2017, 19:03 hmic only on save phantomwatson! on load you would get a casted false back!
# Jul 17th 2017, 19:02 hmic there is way less room for error on the int approach
# Jul 17th 2017, 19:02 phantomwatson So if the field isn't to be changed to true or false, then just take `field => null` out of the data array when you're saving and it will remain null.
# Jul 17th 2017, 19:02 hmic phantomwatson: still would php convert the null to boolean false
# Jul 17th 2017, 19:01 phantomwatson But if you're going for a nullable boolean field, maybe setting the default value to `null` and preventing that field from being included in the call to `save()` if it should stay null would work, too.
# Jul 17th 2017, 19:01 hmic did so too before
# Jul 17th 2017, 19:00 gglow great info, thanks
# Jul 17th 2017, 18:59 phantomwatson I tend to store -1, 0, and 1 for those true/false/null situations, like "approved, dismissed, not addressed yet".
# Jul 17th 2017, 18:59 gglow ok I"ll take a look...
# Jul 17th 2017, 18:59 hmic use an int and define constants for the states, dereuromark might have a plugin or the like
# Jul 17th 2017, 18:59 gglow what do you mean a bit array? Do you mean using a byte/char value and only making use of the first 2 bits?
# Jul 17th 2017, 18:58 hmic if only because of php automatic type casting alone...
# Jul 17th 2017, 18:58 hmic i'd highly recommend not using boolean as a 3 state!
# Jul 17th 2017, 18:57 gglow ok
# Jul 17th 2017, 18:57 gglow ah
# Jul 17th 2017, 18:57 gglow for a 3 state?
# Jul 17th 2017, 18:57 hmic and you can add more than a third state later on :d
# Jul 17th 2017, 18:57 hmic bit arrays should work fine
# Jul 17th 2017, 18:57 jeremyharris though I agree, nulls shouldn’t be saved in a boolean column
# Jul 17th 2017, 18:57 gglow oh?
# Jul 17th 2017, 18:57 gglow it makes sense boolean can only be true or false though:)
# Jul 17th 2017, 18:57 jeremyharris looking at the BooleanType, it should respect null
# Jul 17th 2017, 18:56 gglow should I use a byte instead if I need 3 states?
# Jul 17th 2017, 18:56 hmic bool is true or false, not null. thats it.
# Jul 17th 2017, 18:56 gglow yep
# Jul 17th 2017, 18:56 jeremyharris cake 3?
# Jul 17th 2017, 18:54 gglow When I submit a form with a boolean set to null in my json, CakePHP stores it as false. How do I get Cake to store my null booleans as null and not false?
# Jul 17th 2017, 18:54 jeremyharris https://readthedocs.org/ might work for you then
# Jul 17th 2017, 18:53 devito not very complex
# Jul 17th 2017, 18:52 jeremyharris depends on how complex you need them to be
# Jul 17th 2017, 18:52 jeremyharris lots of people use readthedocs for simpler docs
# Jul 17th 2017, 18:52 devito anyone have suggestions for doumentation generators?
# Jul 17th 2017, 17:57 slackebot <savant>
# Jul 17th 2017, 17:56 megan Lol
# Jul 17th 2017, 17:55 savant you cant set your own points