diff --git a/doc/Configuration-reference.md b/doc/Configuration-reference.md
index 8a62d171..49a783b1 100644
--- a/doc/Configuration-reference.md
+++ b/doc/Configuration-reference.md
@@ -357,7 +357,7 @@ A field is the representation of a property of an entity.
* [`datetime` Field Type](#datetime-field-type)
* [`number` Field Type](#number-field-type)
* `float` Field Type
-* `boolean` Field Type
+* [`boolean` Field Type]
* [`choice` and `choices` Field Types](#choice-and-choices-field-types)
* `json` Field Type
* [`file` Field Type](#file-field-type)
@@ -483,6 +483,28 @@ Format for number to string conversion. Based on [Numeral.js](http://numeraljs.c
nga.field('cost', 'number').format('$0,0.00');
// now 1234.5 will render as '$1,234.50'
+### `boolean` Field Type
+
+A field of type `boolean` can have 3 values: true, false, or null. That's why the form widget for such a field is a dropdown and not a checkbox.
+
+* `choices(array)`
+Array of choices used for the boolean values. By default:
+
+ [
+ { value: null, label: 'undefined' },
+ { value: true, label: 'true' },
+ { value: false, label: 'false' }
+ ]
+
+ Override it with custom labels to fit your needs:
+
+ nga.fields('power_user', 'boolean')
+ .choices([
+ { value: null, label: 'not yet decided' },
+ { value: true, label: 'enabled' },
+ { value: false, label: 'disabled' }
+ ]);
+
### `choice` and `choices` Field Types
* `choices(array|function)`
diff --git a/examples/blog/config.js b/examples/blog/config.js
index 4da752a8..91dfa463 100644
--- a/examples/blog/config.js
+++ b/examples/blog/config.js
@@ -235,8 +235,18 @@
.label('Upper name')
.template('{{ entry.values.name.toUpperCase() }}')
])
+ .filters([
+ nga.field('published', 'boolean')
+ ])
.batchActions([]) // disable checkbox column and batch delete
- .listActions(['show']);
+ .listActions(['show', 'edit']);
+
+ tag.editionView()
+ .fields([
+ nga.field('name'),
+ nga.field('published', 'boolean')
+ .choices([{ value: null, label: 'null' }, { value: true, label: 'yes'}, {value: false,label: 'no' }])
+ ])
tag.showView()
.fields([
diff --git a/package.json b/package.json
index f9994b06..1e0fb7a3 100644
--- a/package.json
+++ b/package.json
@@ -9,7 +9,7 @@
"url": "git://github.com/marmelab/ng-admin.git"
},
"devDependencies": {
- "admin-config": "^0.2.14",
+ "admin-config": "^0.2.15",
"angular": "~1.3.15",
"angular-bootstrap": "^0.12.0",
"angular-mocks": "1.3.14",
diff --git a/src/javascripts/ng-admin/Crud/column/maBooleanColumn.js b/src/javascripts/ng-admin/Crud/column/maBooleanColumn.js
index cdd4eec1..a4669654 100644
--- a/src/javascripts/ng-admin/Crud/column/maBooleanColumn.js
+++ b/src/javascripts/ng-admin/Crud/column/maBooleanColumn.js
@@ -10,9 +10,9 @@ define(function (require) {
value: '&',
},
link: function(scope) {
- scope.isOk = !!scope.value();
+ scope.value = scope.value();
},
- template: ''
+ template: ''
};
}
diff --git a/src/javascripts/ng-admin/Crud/field/maChoiceField.js b/src/javascripts/ng-admin/Crud/field/maChoiceField.js
index 8a8df8b1..4478c613 100644
--- a/src/javascripts/ng-admin/Crud/field/maChoiceField.js
+++ b/src/javascripts/ng-admin/Crud/field/maChoiceField.js
@@ -10,7 +10,8 @@ function maChoiceField($compile) {
'value': '=',
'entry': '=?',
'datastore': '&?',
- 'refresh': '&'
+ 'refresh': '&',
+ 'choices': '&?'
},
restrict: 'E',
compile: function() {
@@ -32,7 +33,7 @@ function maChoiceField($compile) {
refreshAttributes = 'refresh-delay="refreshDelay" refresh="refresh({ $search: $select.search })"';
}
- var choices = field.choices ? field.choices() : [];
+ var choices = scope.choices() ? scope.choices : (field.choices ? field.choices() : []);
var attributes = field.attributes();
scope.placeholder = (attributes && attributes.placeholder) || 'Filter values';
diff --git a/src/javascripts/ng-admin/Crud/fieldView/BooleanFieldView.js b/src/javascripts/ng-admin/Crud/fieldView/BooleanFieldView.js
index e8ea9277..aebdab71 100644
--- a/src/javascripts/ng-admin/Crud/fieldView/BooleanFieldView.js
+++ b/src/javascripts/ng-admin/Crud/fieldView/BooleanFieldView.js
@@ -1,6 +1,6 @@
module.exports = {
getReadWidget: () => '