Hi!
I would like to set a checkbox field (named autorizza_attestato) as readonly for those who do not belong to the admin group.
I used this code in the hook file of my table partecipazione_evento_pubblico but it does not work.
function partecipazione_evento_pubblico_dv($selectedID, $memberInfo, &$html, &$args){
<?php
$form_code = ob_get_contents();
ob_end_clean();
$html .= $form_code;
if(!in_array($memberInfo['group'], ['Admins'])) {
ob_start();
?>
<script>
$j(function() {
$j('#autorizza_attestato').prop('readonly', true);
})
</script>
<?php
$html .= ob_get_clean();
}
}
Any help please?
Thank you!
Fabiano
set a checkbox field as readonly for those who do not belong to the admin group
Re: set a checkbox field as readonly for those who do not belong to the admin group
Hi Fabiano,
use
$j('#autorizza_attestato').attr("disabled", true);
use
$j('#autorizza_attestato').attr("disabled", true);
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.
Re: set a checkbox field as readonly for those who do not belong to the admin group
thanks also for this advice!
I read in the forum somewhere that the "disable" attribute can create data loss. I didn't understand what you meant.
Can I safely use the disable attribute?
the important thing is that if the administrator sets the field in a state and an unauthorized user opens the record and modifies it, not the checkbox field remains in the status set by the administrator
Thanks!
Fabiano
I read in the forum somewhere that the "disable" attribute can create data loss. I didn't understand what you meant.
Can I safely use the disable attribute?
the important thing is that if the administrator sets the field in a state and an unauthorized user opens the record and modifies it, not the checkbox field remains in the status set by the administrator
Thanks!
Fabiano
Re: set a checkbox field as readonly for those who do not belong to the admin group
Hi Fabiano,
when you use the disable attribute, the data for that field will not be passed when the page is submitted. So as you only want the admin to change that field, there is no risk of data loss.
It would be different if you would use that field in a conditional way via another input which would disable the field.
So to my opinion, in your case, you can use it like that.
when you use the disable attribute, the data for that field will not be passed when the page is submitted. So as you only want the admin to change that field, there is no risk of data loss.
It would be different if you would use that field in a conditional way via another input which would disable the field.
So to my opinion, in your case, you can use it like that.
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.
Re: set a checkbox field as readonly for those who do not belong to the admin group
Thank you so much for your explanations!
So i think too that in my case I can use the disable attribute with no risks!
Thanks a lot !!!
Fabiano
So i think too that in my case I can use the disable attribute with no risks!
Thanks a lot !!!
Fabiano