AnsweredAssumed Answered

Custom module relationship - required field

Question asked by Lee Gaska on Oct 28, 2016
Latest reply on Oct 28, 2016 by Lee Gaska

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!