DetailViewDefs CustomCode condition

How can I validate if I am an administrator user to show a button
example in detailviewdefs

<?php
$viewdefs['Accounts']['DetailView']['templateMeta']['form']['buttons'][999] = 
  array (
      'customCode' => '{if $ISADMIN == 1}<form action="/index.php?module=Accounts&action=entityid&id={$bean->id}" method="POST" name="CustomFormEntityID" id="formEntityID">
        <input title="Edit entity id" class="button" type="submit" value="Edit Entity ID">
      </form>{/if}'
  );

You also need to assign the value of $ISADMIN via smarty.
For detail view of module Accounts, Check the file, modules/Accounts/views/view.detail.php

Example variable : custom_code_billing

1 Like

thanks it works

added to view.detail.php

@gstjonathan did you make it upgrade-safe?

Can you please share your solution here so others can benefit from it? Thanks!

To make this upgrade safe. Put view.detail.php in custom directory.