AnsweredAssumed Answered

Dynamically add fields to sub-panel on editiviewdefs.php

Question asked by Jose Rosas on Apr 4, 2017
Latest reply on Apr 11, 2017 by Jose Rosas

Hi All,

I am trying to create non-db fields for a custom module from the Account Module.  I want this fields to be dynamically created so that if anything changes on Account Module, new fields can also be brought to my custom module after rebuild.  In my custom/Extension/modules/customModule/Vardefs/customfields.php  I have:

foreach ($dictionary['Account']['fields'] as $fieldKey => $fieldProp) {
    $fieldProp['source'] = 'non-db';
    $fieldProp['type'] = 'bool';
    $fieldProp['label'] = 'LBL_GANDALF_ACCOUNT_' . strtoupper($fieldKey);
    $fieldProp['name'] = "account__". $fieldKey;
    $dictionary['GDLF_Gandalf_Table']['fields']["account__". $fieldKey] = $fieldProp;
}

I would also like to dynamically declare the fields in my editviewdefs.php.  Hoping to do something like 

foreach ($dictionary['Account']['fields'] as $fieldKey => $fieldProp) {
    $fieldProp['label'] = 'LBL_GANDALF_ACCOUNT_' . strtoupper($fieldKey);
    $fieldProp['name'] = "account__". $fieldKey;
    $customFields[]= $fieldProp;
}

And pass that array to a custom  panel declared in edtiviewdefs.php

'lbl_editview_panel1' => 
array (
  0 =>
  array (
    0 => $customFields
  ),
),

$dictionary[] comes empty is there another way to access the fields from a module form within the editiviewdefs.php?

Thanks in advance.

Outcomes