Add search fields dynamically in popup (opened via relate field in EditView)

Hi,

Iā€™m currently in SuiteCRM version 7.11.18 and i encounter something like a cache problem (from my point of view).

I have exhausted all my ideas and have not seen any answers to my questions in this forum or elsewhere, so iā€™m asking to you, community, if someone already encountered this problem.

Objective:
I would like one of my ā€œrelateā€ field to open a popup with search fields in 99% of the cases and with one search field more in one specific case (when opened from a particular module, letā€™s call it ā€œSpecificModuleā€).

What i did:

  1. In custom/<Module>/controller.php iā€™m currently overriding action_Popup() to conditionally load a different view:
  • $this->view = ā€˜popupā€™; (99% of the cases)
  • $this->view = ā€˜custompopupā€™ in one case (when I open_popup() from my module ā€œSpecificModuleā€)
  1. I have one custom file (view.custompopup.php) for the view loaded in my specific case in which i do
$_REQUEST['metadata'] = 'custompopup';

The goal of this line is to load the file custompopupdefs.php instead of the regular popupdefs.php.
I did this because i saw it used in the display() function from include/MVC/View/views/view.popup.php.

  1. So when i open the popup from the EditView of my module ā€œSpecificModuleā€, the custompopupdefs.php is loaded and i have my additional search field

The problem:
When i open the popup a cache file is generated: cache/themes/SuiteP/modules/<Module>/SearchForm_popup_query_form.tpl.
This file seems to override everything when it exists, if I load one of my popupdefs, the other wonā€™t display what it should:

  • if custompopupdefs loaded first, the additional search field will always be there
  • if popupdefs loaded first, the additional search field will never be there

The only workaround i achieved to find is to erase this cache file (SearchForm_popup_query_form.tpl) before displaying the popup. When i put the below code in the action_Popup() of controller.php it works as expected :

        include_once('modules/Administration/QuickRepairAndRebuild.php') ;
        $repair = new RepairAndClear();
        $repair->repairAndClearAll(array('clearThemeCache'), array(translate('<Module>')), true, false);

This solution to the problem doesnā€™t really suit me. Do you have any idea how to solve this problem?

If you have any questions about my case, let me know

I donā€™t know the answer, you probably have to customize those tpls too, but I am not sure how they are built up

Thank you for your feedback on the subject.
After digging through SearchForm, TemplateHandler, etc. I didnā€™t really continue on this path in the end, I added the field to the popup but I hide it with javascript when I donā€™t need it.

1 Like