Make a Dropdown field read-only for non admin users

Discussions related to customizing hooks. Hooks are documented at http://bigprof.com/appgini/help/advanced-topics/hooks/
Post Reply
Moh Youba
Veteran Member
Posts: 228
Joined: 2017-03-12 09:31

Make a Dropdown field read-only for non admin users

Post by Moh Youba » 2019-09-11 04:45

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,

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1635
Joined: 2018-04-01 10:12

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

Post by pbottcher » 2019-09-11 14:26

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)
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

Moh Youba
Veteran Member
Posts: 228
Joined: 2017-03-12 09:31

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

Post by Moh Youba » 2019-09-11 19:34

Hello

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

Regards,

Moh Youba
Veteran Member
Posts: 228
Joined: 2017-03-12 09:31

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

Post by Moh Youba » 2019-09-11 20:02

Hello
seems I miss something, not working for me
dropdown.jpg
dropdown.jpg (127.66 KiB) Viewed 1658 times
mauritanie.zip
(2.9 KiB) Downloaded 187 times

Thank you

Post Reply