is it possible to hide or show form fields based on data from a php database query?
Can you give an example?
You can hide it completely using a PHP action with Events, this will disable the fields from being added to the form page
Another way is using the "String not empty" trigger (coming in the next update):
in this example, when there is a data parameter named "xyz" present and it's value is not empty then the trigger "hide_me" will be fired which can hide the field
max, thanks for the above answer.
I have tried several approces without success. Also downloaded version 8.0.44. Guess the string not empty is not yet implemented in that version?
You mentionned "You can hide it completely using a PHP action with Events, this will disable the fields from being added to the form page".
Have you a code line for that?
I tried following without success inside a php action before the fields text8,..9..and 10
$fieldsToHide = ['text8', 'text9', 'text10']; // Add all fields you want to hide
foreach ($fieldsToHide as $field) {
if ($cf_id != 8) {
unset($this->fields[$field]);
}
}
Yes, the "String not empty" is available only in v8.0.45
The PHP code can be like this:
if(!empty($this->data("xyz"))){
return "show";
}
then you need an event named "show" in your PHP behaviors > Events, and drag your fields inside that event box
in this case, the "show" event will only run when the "xyz" parameter is not empty