@Bruno. Sorry for the late reply. Yes, this seems to be a proper way to do that.
I tried to change field values onDonFormRender, but there is something going on in the background that prevents me from setting it with js.
Example:
MODx.on('ready',function() {
var value = 8; // =pdf
var path = 1; /* or 2... */
if(path = 1){
var field = Ext.getCmp('modx-resource-content-type');
field.setValue(value);
}
else if(path = 2){
var field = document.getElementsByName('content_type')[0];
field.value = value
}
console.log('value =' + field.value); // Result: 8
});
Console.log returns the expected result, but there is neither a visible change to the content_type combobox nor to the hidden content_type input field. At least the later one should be changed, because this is where the displayed value comes from.
I do this all the time for datefields, select tvs or normal text fields like link_attributes. Never had a problem changing values.
If I open the console and manually type:
Ext.getCmp('modx-resource-content-type').setValue(8)
Both the combobox as well as the hidden input field change to "PDF" and "8".
Its monday, so its not unusual that my gremlins are eager to mess up with my coding, but I don't have a clue whats going on here. If anyone can shed a light, I would be very happy.
Cheers,
pepebe
[ed. note: pepebe last edited this post 12 years, 4 months ago.]