1
0
mirror of https://github.com/flarum/core.git synced 2025-10-12 07:24:27 +02:00

Add check to register state of '0' as false for checkboxes (#2210)

* Add check to register state of '0' as false for checkboxes
* Add comment explaining state === '0'
This commit is contained in:
Alexander Skvortsov
2020-06-28 13:44:14 -04:00
committed by GitHub
parent d93cf4a574
commit e81159249f
2 changed files with 5 additions and 2 deletions

View File

@@ -16,6 +16,9 @@ import icon from '../helpers/icon';
*/
export default class Checkbox extends Component {
view() {
// Sometimes, false is stored in the DB as '0'. This is a temporary
// conversion layer until a more robust settings encoding is introduced
if (this.props.state === '0') this.props.state = false;
let className = 'Checkbox ' + (this.props.state ? 'on' : 'off') + ' ' + (this.props.className || '');
if (this.props.loading) className += ' loading';
if (this.props.disabled) className += ' disabled';