Page 1 of 1

disable Date for non admins

Posted: 2022-07-26 16:47
by angus
Hi I have tried to disable the date field (it has 3 drop downs, one for day, one for month and one for year) for non admins but have had no success. I have another field that needs to be disabled and it is working ok. Just cant get the Date to be disabled.

Has anyone got this working and could share it with me?

This is a part of the code I am using in the hooks file under function tablename_dv

Code: Select all

                    $html .= <<<EOC
                                        <script>
                                              \$j(function(){
											  \$j('#Name').prop('readonly', true);
											  \$j('#Date').prop('readonly', true);									  
                                              })
                                        </script>
EOC;
I have tried the following by looking at the dml file

Code: Select all

\$j('#DateDay').prop('disabled', true)
\$j('#DateMonth').prop('disabled', true)
\$j('#DateYear').prop('disabled', true)
this didnt work either.

Re: disable Date for non admins

Posted: 2022-07-26 17:31
by angus
OK, I have tried various other permutations and have got everything disabled except the clear button

Code: Select all

\$j('#Date').prop('disabled', true);	
							 \$j('#Date-dd').prop('disabled', true);
							  \$j('#Date-mm').prop('disabled', true);
							  \$j('#fd-but-Date').prop('disabled', true);
							  \$j('#fd-date-clearer').prop('disabled', true);
if anyone knows how to disable this that would be useful

Re: disable Date for non admins

Posted: 2022-07-26 19:31
by pbottcher
Hi,

if you only have one date selection you can try

Code: Select all

$j('.fd-date-clearer').prop('disabled',true)
Otherwise you would need to traverse the date selection from the top class towards the clearer.

Re: disable Date for non admins

Posted: 2022-07-26 21:49
by angus
Pbottcher, this is it, perfect. thank you