Skip to content

Instantly share code, notes, and snippets.

@nkb-bd
Last active November 10, 2022 03:51
Show Gist options
  • Save nkb-bd/465b45bcf886a7931d476079ed14039d to your computer and use it in GitHub Desktop.
Save nkb-bd/465b45bcf886a7931d476079ed14039d to your computer and use it in GitHub Desktop.
Fluent Form Repeater Field Unique validation
add_filter('fluentform_validate_input_item_repeater_field', function ($errorMessage, $field, $formData, $fields, $form) {
$name = 'repeater_field';
$data = $formData[$name];
$col_index = 0;
$values= array_column($data,$col_index);
$unique_count = count(array_unique($values));
$count = count($values);
if($unique_count != $count){
return[ "Error! Duplicate"];
}
return $errorMessage;
}, 10, 5);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment