Field Data Type: Boolean
This explains Boolean Fields. For an overview check out Understanding Data....
The Boolean Data Type
Boolean data is a basic data type and is for yes/no, true/false, 1/0 values.
It can also contain null values.
Features
The basic boolean field doesn't have any features, since all the features are in the sub-types.
Configuration
Every boolean field can be configured to have special labels shown in each state.
Input-Types of Boolean Fields
- boolean-default - simple on/off input field
- boolean-tristate on/off with optional null (not-defined)
Technical Information
Storage in the SQL Database in the EAV-Model
This is converted to a string when stored as a string in the DB, and converted back to a boolean when the data is loaded.
Storage in the SQL Database in the JSON-Model
This is simply stored as a true, false or null in json.
Null Value Possible
In some cases you may add a field to a type which already has Entities created previously. In this case the old data doesn't have a value for the field.
If this happens, the field will return null, so you may need to catch this special exception in your code.
A common shorthand to work with nulls is the
??operator:@(Content.IsAdult ?? false)
Another common use is to check for
true. So instead of@if(Content.IsAdult) {...}Useif(Content.IsAdult == true) {...}
History
- Introduced in EAV 1.0 2sxc 1.0