Home Forums Add-ons Repeater Field validate a repeater field


validate a repeater field

  • I’m trying to work out how to validate a repeater field. The first field contains a minimum age; the second field contains a maximum age. I want to validate the minimum age by comparing it to the maximum age.

    With the “normal” (not repeater) field I use this.

    add_filter('acf/validate_value', 'my_validate_form', 10, 4);
    function my_validate_form( $valid, $value, $field, $input ){
    	if ( $field['name'] == 'min_age' ) {
    		// get the value of max age
    		$maxAge = $_POST['acf']['field_5d28712c42a47'];
    		if ( $value > $maxAge )
    			return "min is greater than max";
    			return true;
    	return true;

    But this isn’t working with repeater rows. In this case I am trying to find out how to firstly get the value of the specific min/max ages on a row, and then return an error message just for that row.

    Any help appreciated! 🙂

Viewing 1 post (of 1 total)

The topic ‘validate a repeater field’ is closed to new replies.