Getting type select to set value based on jcr property
Im creating a custom xtype and Im running into an issue where I cant seem to pull the jcr property and set the default value to the jcr property value each time the page refreshes.
So for example, if I set the defaultValue to Option A and the user select Option B, Option B will be set as the default but once the user refreshes the page, the defaultValue returns to Option A and not Option B. Is there a way where I can set the defaultValue to Option B or in other words to what the user selects?
this.optionsField = new CQ.form.Selection({
type:'select',
hideLabel: true,
defaultValue: 'p',
value: 'p',
fieldDescription: 'Select header tags in semantic order. If no header tag is needed indicate “p”',
options : [
{
value: 'p',
text: 'p'
},
{
value: 'h1',
text: 'h1'
},
{
value: 'h2',
text: 'h2'
}
],
listeners: {
selectionchanged: {
scope: this,
fn: this.updateHidden
}
}
});
this.add(this.optionsField);
},
setValue: function (value) {
this.setValue(this.getValue());
this.optionsField.setValue(this.getValue());
this.hiddenField.setValue(this.getValue());
},
//calls CustomCTAField#getRawValue
getValue: function () {
//console.log("CustomCTAField#getValue");
return this.getRawValue();
},
//this gets the value of each of the following fields
//then puts them into a JSON object which we use later.
//a good example of usage is seen in CustomCTAField#setValue
getRawValue: function () {
return this.optionsField.getValue()
},
updateHidden: function () {
//alert(this.getValue());
// this.hiddenField.setValue(this.getValue());
this.setValue(this.getValue());
}