How do I disable a field yet visible?

So I have tried all methods I could find.

  1. When I set Data Type readonly, it hides the field.
  2. When I check readonly property true under Permission (I have tried all data types, Data, Int, Float, Text), it hides the field as well. Interestingly this does show the field of old records only if it has any data, but for new records or when it doesn’t have any data this approach hides the field.
  3. I have tried both scripts :

frm.set_df_property(“field_name”, “read_only”, 1)
frm.toggle_enable(“field_name”, 0);

Neither of these work, they just hide the field.

I don’t know what I’m doing wrong, I’m totally lost here.

Hi, @Adeel_Siddiqui

You can try this code this might help you out.

frappe.ui.form.on('Doctype', {
	refresh: function(frm) {
		var field = frm.get_field("fieldname");
		field.$input.prop('readonly', true);
	}
});

Thank you.

1 Like

Thanks!