Here is what I found, in the CRED form "Create content - Answers ":
1) you are using below custom shortcode to display the field "newparent",
[kkutraki_new_sample_select]
it is not a CRED shortcode, which is out the range of Toolset support, I suggest you ask help from the shortcode author to check if it is possible to use the custom shortcode [kkutraki_new_sample_select] to display the error message
2) And in the problem page:
hidden link
The shortcode [kkutraki_new_sample_select] does not display any options in the dropdown field, so it is not possible to test it in your website
3) and I setup a demo to use filter hook "cred_form_validate" in your website:
a) Edit the CRED form "Create content - Answers", line 7, modify the codes from:
[kkutraki_new_sample_select]
To:
[kkutraki_new_sample_select-1]
<select name="newparent1" class="form-control" output="bootstrap" required="" id="8200">
<option value="650">Test1</option>
</select>
[cred_generic_field field='display_msg' type='hidden' class='' urlparam='']
{
"required":0,
"validate_format":0,
"default":"0"
}
[/cred_generic_field]
It will output a dropdown menu field "newparent1" and a hidden generic field "display_msg"
3) Since you did not provide FTP access, so I use "code snippet" plugin to add below PHP codes:
hidden link
add_filter('cred_form_validate', 'custom_check_answer_exists', 10, 2);
function custom_check_answer_exists($error_fields, $form_data) {
list($fields,$errors) = $error_fields;
if ($form_data['id']==171){
$sample_id = $_POST['newparent1'];
$answered_sample_list = array(650);
if (in_array($sample_id, $answered_sample_list)) {
$errors['display_msg']='Already submitted!';
}
}
return array($fields,$errors);
}
It will be able to check if "newparent1" field is value 650, then output the error message.
You can test the result here:
hidden link