I have a checkbox that 90% of the time user will just select either YES or NO. Always enabled.
But when I retrieve a record under certain criteria I want to ensure the checkbox is selected with the NO option and DISABLED so user cannot change it.
I have the IF condition working, just don't know the syntax on how to get this to go to NO, and then disable the checkbox.
use php:
$this->set("checkbox_disabled", false);
if(condition){
$this->data["checkbox_name"] = 0;
$this->set("checkbox_disabled", true);
}
then add {var:checkbox_disabled} in the disabled field in the checkbox settings!
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
Thanks Max, code is usable, however, I can get only checkbox disabled, bu cannot get it enabled. How that should be done? The code below not working.
obviously $this->set("checkbox_disabled", false); is not the right code😀
<?php
$klatiene= $this->data['klatiene'];
$klatiene_skaits=20;
$skaits=$this->data['skaits'];
// Izrekina atlikušo skaitu
$klatiene_atlikums=$klatiene_skaits-$klatiene;
// paziņojums
$this->set("checkbox_disabled", false);
if($klatiene_atlikums< $skaits) {
echo "Vietu skaits klātienē ir beidzies!";
$this->data["checkbox_name"] = 1;
$this->set("checkbox_disabled", true);
} else{
echo "<p>Atlikušais vietu skaits klātienē: " . $klatiene_atlikums . " vietas</p>";
$this->data["checkbox_name"] = 1;
$this->set("checkbox_disabled", false);
}
$this->data['klatiene_atlikums']=$klatiene_atlikums;
?>
But when I retrieve a record under certain criteria I want to ensure the checkbox is selected with the NO option and DISABLED so user cannot change it.