The above code correctly overrides the set_link_title method for link fields in child tables. However, it does not seem to affect the link fields in the parent form. I would like to understand why this is happening and how to ensure that the changes apply to link fields in both child and parent forms.
As you extend the main class ControlLink, it will be applied to all link fields, both child and parent. If this does not work, could you elaborate more on the issue and provide some code and steps on how you are doing it?
frappe.ui.form.ControlLink.prototype.get_translated = function (value) {
let link_doctype = this.get_options();
return this.is_translatable() ? __(value, null, link_doctype) : value;
}
Key Difference:
In the solution, the get_translated method is added directly to the prototype of frappe.ui.form.ControlLink. Using the prototype allows the method to be applied to all instances of ControlLink, including those in both child tables and the parent form.
Original Code: Defined a new class CustomControlLink which only affected specific instances of ControlLink.
Solution: By using prototype, the get_translated method is injected into the existing ControlLink class, ensuring it works for both child and parent forms across the board.
Tip: To Apply the Solution Globally to All Doctypes:
To ensure this solution applies to all doctypes in your Frappe application, include the following code in your_app/public/js/: