Hello. Thank you for contacting the Toolset support.
As I understand - you have a Toolset post form having repeating image field and you want to make sure that people must add at least three images and the image is selected using the media library - correct?
Please correct me if that is not the case you are having.
add_action('cred_form_validate', 'func_validate_image_count',10,2);
function func_validate_image_count($error_fields, $form_data) {
$forms = array( 99999 );
// Field data are field values and errors
list($fields,$errors)=$error_fields;
if (in_array($form_data['id'], $forms ) && (isset($_FILES['wpcf-book-images']['type']))) {
if ( count( $_FILES['wpcf-book-images']['name'] ) < 3 ) {
$errors['wpcf-book-images'] = 'Add at least 3 images';
return array( $fields, $errors );
}
//return result
return array($fields,$errors);
}
Where:
- Replace 99999 with your original form ID
- Replace book-images with your original field slug
I would like to know, do you mean that you want to validate the maxinum number of image selection at the time user select the images from media uploader dialog box?
As, the validation hook I shared will be run when you submit the form.