Pārlūkot izejas kodu

[Docs] Added new article to add custom button to a form (#2364)

version-14
Shreyas Patil pirms 8 gadiem
committed by Rushabh Mehta
vecāks
revīzija
8cb27f8366
2 mainītis faili ar 27 papildinājumiem un 0 dzēšanām
  1. Binārs
      frappe/docs/assets/img/app-development/add_custom_button.png
  2. +27
    -0
      frappe/docs/user/en/guides/app-development/adding-custom-button-to-form.md

Binārs
frappe/docs/assets/img/app-development/add_custom_button.png Parādīt failu

Pirms Pēc
Platums: 1918  |  Augstums: 644  |  Izmērs: 88 KiB

+ 27
- 0
frappe/docs/user/en/guides/app-development/adding-custom-button-to-form.md Parādīt failu

@@ -0,0 +1,27 @@
To create a custom button on your form, you need to edit the javascript file associated to your doctype. For example, If you want to add a custom button to User form then you must edit `user.js`.

In this file, you need to write a new method `add_custom_button` which should add a button to your form.

#### Function Signature for `add_custom_button(...)`
frm.add_custom_button(__(buttonName), function(){
//perform desired action such as routing to new form or fetching etc.
}, __(groupName));

#### Example-1: Adding a button to User form
We should edit `frappe\core\doctype\user\user.js`

frappe.ui.form.on('User', {
refresh: function(frm) {
...
frm.add_custom_button(__('Get User Email ID'), function(){
frappe.msgprint(frm.doc.email);
}, __("Utilities"));
...
}
});

You should be seeing a button on user form as shown below,

![add_custom_button_screenshot](/assets/img/app-development/add_custom_button.png)

<!-- markdown -->

Notiek ielāde…
Atcelt
Saglabāt