I have code in js to populate a Select field (populate the options df_property). It works well. I can select the values.
But my problem now is to keep the field displaying the selected value.
After Save, if I reload the page the field is blank.
Examining from the browser console I can see the field has the selected value, but just not displaying it.
The select field kotakabupaten
is populated based on selection of another field propinsi
:
propinsi: function ( frm ) {
frappe.call( {
method: "frappe.client.get_list",
args: {
'doctype': "Wilayah",
'filters': { 'nama_propinsi': frm.doc.propinsi },
'fields': [
'nama_kota_kab'
]
},
callback: function( r ) {
if ( r.message ) {
let arrayKokab = [];
for ( let i = 0; i < r.message.length; i++ ) {
var kokab = r.message[ i ].nama_kota_kab;
arrayKokab.push( kokab );
}
let unikKokab = [ ...new Set( arrayKokab.sort() ) ];
frm.set_df_property( 'kotakabupaten', 'options', unikKokab );
}
}
} );
},
How do I keep displaying the selected value?
I don’t want to change the fieldtype to Data because I want the user to be able to later change the selected value.
Thank you