How to add custom create button on popup search window for custom module?

-I have create one custom module(category) and create relation with account module(1 to many)

now i want this button of 'create category' on popup search of category in account module

(from Ishani Lad)
  • Yep, would be useful to know how to add a Create Record button in a custom module... similar to what happens with the SugarCRM Accounts module on Search popup...     Thank you!  (from danelige)
  • Hiii danelige !!  I get the solution and its work perfect :-)  custom/modules/custom module/cityFormBase.php(need to create)  same file also add in module/custom module/cityFormBase.php Add code : save();  } }  ?>  custom/modules/Custom_module /meta data/popupdef.php Add code this code in popupdef.php  'create' =>  array('formBase' => 'key_CityFormBase.php',  'formBaseClass' => 'key_CityFormBase',  'getFormBodyParams' => array('','','key_Citysave'),  'createButton' => $mod_strings['LNK_NEW_RECORD']   ),  Then repair and check ...  All the best !!  (from Ishani Lad)
  • I tried to follow these steps, but I have not been successful
    1- In custom/modules/<MyModule>/metadata/popupdef.php file,I added the following lines :

    'searchInputs' => array (....),

    'create' =>
    array('formBase' => 'MyModuleFormBase.php',
    'formBaseClass' => 'MyModuleFormBase',
    'getFormBodyParams' => array('','','MyModulesave'),
    'createButton' => $mod_strings['LNK_NEW_RECORD'] 

    ),

    after that , I did a quick repair, but I got errors, 


  • it's good, it works
    solution:
    **********
    After adding the above code to the file: <root>/custom/modules/<MyModule>/metadata/popupdef.php
    --------------------------------------------------
    Step 2: I create a file:
        <root>/custom/modules/<MyModule>/<MyModule>FormBase.php, the content:

    <?php
    if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
    require_once('include/SugarObjects/forms/FormBase.php');

    class MyModuleFormBase extends FormBase {

          var $moduleName = 'MyModule';
          var $objectName = 'MyModule';

          function handleSave($prefix, $redirect=true, $useRequired=false){
          require_once('include/formbase.php');
          $focus = new MyModule();
          $focus = populateFromPost($prefix, $focus);
          $focus->save();

    }
    }

    ?>

    I keep a copy of this file that I put to:
    <root>/modules/<MyModule>/<MyModule>FormBase.php

    Finally a quick repair, does the trick
  • but I found a bug, when I pass in studio-> MyModule-> Page Setup-> View popup, the following error appears:
    Notice: Undefined variable: mod_strings in <root> \ custom \ modules \ <MyModule> \ metadata \ popupdefs.php on line 26
    namely: at this level 'CreateButton' => $ mod_strings ['LNK_NEW_RECORD']