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: 67
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,

pböttcher
AppGini Super Hero
AppGini Super Hero
Posts: 549
Joined: 2018-04-01 10:12

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

Post by pböttcher » 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)

Moh Youba
Veteran Member
Posts: 67
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: 67
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 45 times
mauritanie.zip
(2.9 KiB) Not downloaded yet

Thank you

Post Reply