conditionallay showin/hiding fields

Conditionally show or hide a form field based on array count.

Overview

The issue occurs when a PHP event switcher fails to properly evaluate whether an array contains exactly two elements.
Use the PHP action with the Events behavior directly, placing the dependent field within the "yes" event to control its visibility.

Answered
ChronoForms v8
kr kraadde 02 Jun, 2025

I have  an Array "teiln_dat" with 0 to 2 Elements like "yyyy-mm-dd".

I want to show or hide a further field depending on the condition that "teiln_dat" has 2 Elements.

I tried with a php104 as an Event switcher:

if (isset($this->data['teiln_dat']) && is_array($this->data['teiln_dat']) && count($this->data['teiln_dat']) === 2) {    return 'yes';} else {    return 'no';} 

but seems not to work.Is there a better solution that works in the browser or likely a JSsript?

Max_admin Max_admin 05 Jun, 2025
Answer

You can use the PHP action with the Events behavior directly and place the other field in the "yes" event

Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Post a Reply