Page 1 of 1

Make a Dropdown field read-only for non admin users

Posted: 2019-09-11 04:45
by Moh Youba
Hello

I am using AppGini 5.76

I have a Lookup field named "statut" in a table named "mauritanie". I want to make "statut" read-only for non admins users. I have try all post in the forum but still cannot do it.

Thanks for any help

Regards,

Re: Make a Dropdown field read-only for non admin users

Posted: 2019-09-11 14:26
by pbottcher
Hi,

you may try this in the hooks/mauritanie.php file, add to the mauritanie_dv function:

Code: Select all

		 $html .= <<<EOC
<script>
function waitForElementToDisplay(selector, time) {
        if(document.querySelector(selector)!=null) {
			\$j('#statut-container').select2('readonly',true);
            return;
        }
        else {
            setTimeout(function() {
                waitForElementToDisplay(selector, time);
            }, time);
        }
    }
waitForElementToDisplay('#s2id_statut-container', 1000);
</script>
EOC;
Make sure the ending EOC; is at the beginning of the line (no spaces or tabs in that line)

Re: Make a Dropdown field read-only for non admin users

Posted: 2019-09-11 19:34
by Moh Youba
Hello

Thank you for the help, going to try and back to you.

Regards,

Re: Make a Dropdown field read-only for non admin users

Posted: 2019-09-11 20:02
by Moh Youba
Hello
seems I miss something, not working for me
dropdown.jpg
dropdown.jpg (127.66 KiB) Viewed 1665 times
mauritanie.zip
(2.9 KiB) Downloaded 188 times

Thank you