Read Only vs dropdown menu

I am trying to adapt this code snippet for a situation I have:

I would like that for an normal user the field “Assigned to:” appears readonly instead for the amministrator I would like the dropdown menu.

But it doesn’t work.

'customCode' => '{if $ReadOnly == "readonly"}<span>{$fields. assigned_user_name.value}</span>{else}{html_options name="assigned_user_name" id="assigned_user_name" options=$fields. assigned_user_name.options selected=$fields. assigned_user_name.value}{/if}',

Is there anybody who can help me?

I have the same need, in my edit view I need to keep readonly a dropdown that is part of the other dynamic dropdown, when I put type = ‘readonly’ the second dropdown does not show any data. I read that readonly does not apply to dropdown. I am using Suitecrm 7.11.15 and I did not find view.edit.php in custom/modules/AOS_Quotes/views/view.edit.php as show Read-only fields based on Roles

The dropdown need to apper and to read bu teh formulary in edit view to allow interact with the dynamic dropdown.

@eih64
The code work.

'customCode' => '{if is_admin($current_user)} @@FIELD@@ {else} <input class="sugar_field" id="assigned_user_name" readonly="readonly" value="{$fields.assigned_user_name.value}">{/if}',

Thanks for your quick answer. But I really new with PHP and I afraid to damage the standard code. Could you told me the route and position of this code in the PHP file. ej. custom/module/modulename/ metadata/editview.php below array definition or something else.

@ariajf00
There is example. You should write correct values for:

  • ‘lbl_…’ - label of panel;
  • ‘<number of row>’
  • ‘<number of column>’
    'panels' =>
    array(
      'lbl_...' =>
      array(
...
       <number of row> =>
        array(
...
          <number of column> =>
          array(
            'name' => 'assigned_user_name',
            'label' => 'LBL_ASSIGNED_TO_NAME',
            'customCode' => '{if is_admin($current_user)} @@FIELD@@ {else} <input class="sugar_field" id="assigned_user_name" readonly="readonly" value="{$fields.assigned_user_name.value}">{/if}',
          ),
...
        ),
...
      ),
1 Like

Solved thanks a lot. The dropdwon appear as readonly and the dynamic drop down works well.