Last active
November 10, 2022 03:51
-
-
Save nkb-bd/465b45bcf886a7931d476079ed14039d to your computer and use it in GitHub Desktop.
Fluent Form Repeater Field Unique validation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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