Is it possible to get values from the 'field' data (the post fields) when using the filter 'rwmb_frontend_validate' so i can check what setting/attribute was used?
add_filter( 'rwmb_frontend_validate', function( $validate, $config ) {
// Check only if you're on the right form.
if ( 'your-meta-box-id' !== $config['id'] ) {
return $validate;
}
// Check if users have selected files for an image upload field.
if ( empty( $_POST['image_upload_field'] ) ) {
$validate = false; // Return false to show an error message.
}
return $validate;
}, 10, 2 );
Please try this on your end and let me know how it goes.
Sorry i must have not been clear enough, when i mentioned the 'field' data, this is the field settings like you can get when sanitizing a field e.g. of $field below. But can this be done in the front end validation? I need to check a form fields attribute value during the front end validation.
function my_sanitize_money_field( $value, $field, $old_value, $object_id )
The filter rwmb_frontend_validate doesn't pass the field settings to the callback function. You can use the helper function rwmb_get_field_settings to get the field settings.
Please follow the documentation https://docs.metabox.io/functions/rwmb-get-field-settings/