Custom module relationship - required field

Hello, All.

I have a custom module with a relationship created to the Accounts area. When I create the relationship in module builder (in Enterprise 6.5.24), a field (mpmr_pcr_accounts_name) is added to the edit and detail views. I want this field to be required, so after the module is deployed, I modify the vardefs by adding 'required' => 'true' to the array  in /custom/Extension/modules/MyCustomModule/Ext/Vardefs/. I have created a separate package to deploy this change after the module is deployed. Example below from vardef:

$dictionary["MPMR_PCR"]["fields"]["mpmr_pcr_accounts_name"] = array (
  'name' => 'mpmr_pcr_accounts_name',
  'type' => 'relate',
  'source' => 'non-db',
  'save' => true,
  'id_name' => 'mpmr_pcr_accountsaccounts_ida',
  'link' => 'mpmr_pcr_accounts',
  'table' => 'accounts',
  'module' => 'Accounts',
  'rname' => 'name',
  'required' => 'true',

This accomplishes what I needed to do, but it hardly seems correct. My questions is, is there a better way to make a field created via a relationship in the module builder required? Is this something that can be specified in the module manifest? I know I can create a relate field in the module builder, but adding a second field doesn't seem correct either.

Any thoughts are appreciated. Thanks!


  • Hi Lee Gaska

    In you package you can search for the same field and add 'required' => 'true', where your field's vardef is present.

    If you are installing another package for making the field true the below code would be enough in your module extension directory. 
    $dictionary["MPMR_PCR"]["fields"]["mpmr_pcr_accounts_name"] ["required"]= true; //this would be enough the remaining declarations are not necessary



  • Hi, Sidhu.

    Thank you for your reply, it has been helped. I was using the "Export" feature from the module builder, and that was why I was not seeing the field exist in my module package vardefs. If the "Publish" feature is used the vardefs are created inside the package. I'll probably go with creating a second second package for now taking into account your note on unnecessary declarations.

    Thanks again,