How do I make a field readonly for users but also make the field so that it can be populated by field_to_name_array?
I want to use the field_to_name_array to populate a field in Module B
which I know how to do (see below)
and
I want the result shown to the user
which I know how to do
BUT
I want the result, when shown to the user to be readonly
and that last part I cannot make work with the first (2) parts
If I set the display field to readonly in editviewdefs using any of the three methods I have tried (see below), it prevents the field_to_name_array from populating the field now set to readonly
Here is what I have:
In my custom module AYU_Funds I am populating 2 fields:
- fund_addr_city
- fund_addr_street
by pulling their values from the Accounts module via a Relate field in AYU_Funds pointing to Accounts and using a field_to_name_array in custom/modules/AYU_Funds/metadata/editviewdefs.php
1 =>
array (
'name' => 'parent_name',
'studio' => 'visible',
'label' => 'LBL_PARENT_NAME',
'displayParams' =>
array (
'field_to_name_array' =>
array (
'name' => 'parent_name',
'id' => 'parent_id',
'primary_address_city' => 'fund_addr_city',
'primary_address_street' => 'fund_addr_street',
),
'additionalFields' =>
array (
'primary_address_city' => 'fund_addr_city',
'primary_address_street' => 'fund_addr_street',
),
),
),
So far so good, all works well; the fileds in AYU_Funds are populated by the values in the Account to which the AYU_Funds module is related
I want the user to be able to see the results of the data pulled from Accounts but I do NOT want the user to be able to edit the fields showing the data.
I have tried three ways to make the fields readonly in the Edit View of AYU_Funds, all of which work to make the field readonly but all of which also prevent the field from being populated by field_to_name_array.
Here are the three methods I have tried to make a field readonly to users by adding to its definition (fund_addr_city shown - same thing tried with find_addr_street) in editviewdefs.php:
0 =>
array (
'name' => 'fund_addr_city',
'label' => 'LBL_FUND_ADDRESS_CITY',
'type' => 'readonly',
),
0 =>
array (
'name' => 'fund_addr_city',
'label' => 'LBL_FUND_ADDRESS_CITY',
' displayParams' => array(
'readonly' => true,
)
),
0 =>
array (
'name' => 'fund_addr_city',
'label' => 'LBL_FUND_ADDRESS_CITY',
'customcode' => '{$fields.fund_addr_city.value}'
),
All of the above do the same thing: make the field readonly but also prevent the field from being populated by field_to_name_array
How do I make a field readonly for users but also make the field so that it can be populated by field_to_name_array?