View Full Version : Initializing a checkbox with "value" config

mono blaine
11 Apr 2013, 3:44 PM
Ext.form.field.Field mixin provides a value config to initialize fields with a default value and nearly all form fields obey that. (Radio field could be an exception, I don't know) However a checkbox field should be initializable with a value:

This doesn't work:

Ext.create('Ext.form.Panel', {
renderTo: Ext.getBody(),
width: 300,
items: [{
xtype: 'checkbox',
boxLabel: 'foo',
name: 'bar',
value: true

Using checked instead of value is a solution, but it is not meaningful.

Honoring the value config and also giving him a higher precedence over the checked config is much better:

Ext.define("Foo.override.form.field.Checkbox", {
override: "Ext.form.field.Checkbox",

constructor: function (cfg) {
cfg = cfg || {};

if (Ext.isBoolean(cfg.value)) {
cfg.checked = cfg.value;


12 Apr 2013, 8:22 AM
Thanks for the feedback!
For the checkboxes and radiofields (which extend checkboxes) checked will determine if the component shows as 'checked' and inputValue will the be underlying value associated with the field element.