Way to add links to Manager editing screens?

Has anyone found a way to add links (or HTML text in general) to manager editing screens? For example, I have a site with speakers that are linked to companies:

The company list is pulled from a “Companies” Collection. I’d love to be able to be an “EDIT” button right under the Company popup to go directly to the company resource to edit it.

So what is the “Company” dropdown? A normal TV that you moved to this position with Form Customization?

Yes, exactly.

I can change the field label and add HTML containing a link, but that would be a static link. Here, I would need a link with the ID selected in the Companies popup.

My guess is that you have to write some javascript code to achieve this and add it on a MODX event.

For example on the event “OnDocFormPrerender” run some plugin code similar to the example on this page of the documentation.

Code like this might work (or it might not work, I’m no Ext.js expert):

Ext.onReady(function() {
    setTimeout(function() {
        var tv_id = 5; // <-- change this to the ID of your TV
        el = Ext.getCmp("tv" + tv_id);
        if (el) {
            // Add a select listener to the TV component
            el.on(
                "select",
                function(e,t) {
                    console.log("value changed to: " + t.data.value);
                    // Do something else with the new value ...
                },
                this
            );
        }
    }, 2000); // You might have to set a timeout so that the TV-component is available when the code runs
});

Thanks, will give that a try!

Hey, it works! I just created the link in the label and made the javascript update that on loading or changing the TV. Can’t believe it was this simple.

1 Like