How to Hide Save Button

Hi,
I need to know that is there any way that I can hide save button using script.

I have tried below script, but it is raising an error
Uncaught TypeError: Cannot read property ‘appframe’ of undefined

cur_frm.cscript.custom_refresh = function() {
if(cur_frm.doc.purpose==“Material Transfer”) {
if(!cur_frm.doc.__islocal && cur_frm.doc.owner === wn.boot.profile.name) {
cur_frm.frm_head.appframe.clear_buttons(‘Submit’);
cur_frm.frm_head.appframe.add_button(‘Save’, function() { cur_frm.save(‘Save’);}, ‘’);
cur_frm.frm_head.appframe.buttons[‘Save’].addClass(‘btn-info’);
}
}
}

trigger this on refresh event.

frm.disable_save();

1 Like

Thanks a lot.
Can you tell me one thing.
Is there any way to enable/disable or hide/unhide attach file button.
Actually I though that hiding save will solve my purpose but I was wrong.
I want that once the task is saved nobody can delete any attachment from it.

Regards
Ruchin

I believe that is not possible at the moment. can you please raise a feature request on github.

I need to disable submit on a condition, say payment option (select datatype) is pending,
i tried frm.disable_save();
frm.disable_save() disables saving and hides the save/submit button which is good.

I need to enable the button again when payment option is paid,
i tried frm.enable_save()
frm.enable_save() just enables save, button is not shown

Why am i not seeing the save/submit button ? tried frm.refresh also.

Can anyone please tell me how to toggle save and submit .

@ninjas005 Please share a link to your code.

@neilLasrado
here is my code

frappe.ui.form.on("Work Order", "payment_status", function(frm) 
{
		if(!frm.doc.__islocal)
			if(frm.doc.payment_status=='pending')
				frm.disable_save();
			else
				frm.enable_save();
		frm.refresh();
}
);
2 Likes

@ninjas005 this must work. found similar code here frappe/website_theme.js at develop · frappe/frappe · GitHub

the code is working @neilLasrado

but the problem is with the save button. its not showing when i enable it from disable mode.
so, ctrl+s must be used to save the form.

You can put this code:

frm.save_disabled=false;
frm.page.set_primary_action();
frm.refresh();

That works fine for me.

Hi all

I write another way hide submit button
=> add frappe.validated = false in before_submit;
==> user can’t submit.

Here my code

frappe.ui.form.on("Delivery Note", "before_submit", function(frm){
		frappe.validated = false;
});
1 Like

Does “before_submit” works in form?

cur_frm.disable_form();
this will dissable form and also removed save btn