index of repeater in php validation function

Validate a dropdown field based on a checkbox within the same repeater row.

Overview

The validation function for a field inside a repeater cannot directly access the index of its row to check another field in that same row.
Use a Pre-Submit action with a PHP action to perform the validation. In this action, you can loop through the repeater data, check the condition for each row, and add any error to the specific field by name to display it correctly.

Answered
ChronoForms v8

i have a checkbox and a dropdown field in a repeater. the validation php code of the dropdown field depends on the checkbox value. 

how can i access to the checkbos of the corresponding checkbox?

I don't now how to access the index of the reapter in the php code.

Max_admin Max_admin 14 Jan, 2026
Answer

Hi juerg

You can enable the form debug and check the data array after you submit the form page, it will show the data structure, if both fields are inside the repeater then you will access them the same way using a PHP loop over the repeater array

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

But i need the row in the validation php not in the submit php. In row 2 i have to check if a valid data is set based on the value of an other field in the same row.

I get only the $value variable in the php code and not the row

if ($this->data[p][?] ==1 && value == 0) {

  return " Error";

}

How can i get the value of ? the must be the same row as $value

i can't use triggers and listener as they are not specific to a container row .

Max_admin Max_admin 15 Jan, 2026

Hi Juerg

You can not do it this way with a repeater, you need to use the Pre Submit action and add a PHP action inside where you can run your code and update the $this->errors array with the error message you need:

index of repeater in php validation function image 1

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

Hi Max

I was afraid of that. So the errors don't appers near the field, who cause the error. It appears on the top of page and it is not clear in wich of the reapter the error occurs.

But so..

Max_admin Max_admin 16 Jan, 2026

Hi juerg

No problem, you can add the error to the field by setting the error under the field name:

$this->errors["first_name"] = "First name is incorrect";
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.

Hi Max

that doesn't work with fields in a repeater. i use the fieldname first_name[1] 

the errors are displayed at top of the form.

Post a Reply