Posted by Shaun
2015-07-08

Hi Tom,

Thanks for a great script. I am looking to modify it such that non admin users can only edit certain fields. I tried 'hiding' these fields by editing tpl.xxx.detail.inc.php to only show certain fields if not an admin user, which works fine, but when I click 'save', I run into issues about required fields being empty - even though they are not displayed . Any suggestions on how to sort this out, or a better solution?
Posted by Tom
2015-07-09

What you did is the correct first step. The second step is to remove '(fd)' for those fields. To do so, open web/codelib/asc/df.fl.(table-name).inc.php. You will find a line like this for most of fields.
XA_LIST=>'(fd)'
If you remove (fd) from the line, then the field will be ignored in the detail page.
Since you want to conditionally remove it, you can add the code like this on the bottom of the page, df.fl.(table-name).inc.php
if ( !$sys->IsAdmin() ) {
$spec['fieldname1'][XA_LIST] = '';
$spec['fieldname2'][XA_LIST] = '';
$spec['fieldname3'][XA_LIST] = '';
............................
............................
............................
............................
}
Note that you need to replace fieldname1,fieldname2,fieldname3 with the fields you want to remove from the detail page.