Referencing field entry with one on another form

Hi,

I have two forms – an application form  and a reference form. In order to link the two forms, I have set an ID field in the application form when is then sent to the person completing the reference form, which they then enter on their form. This all works perfectly, but is there a way of checking the ID entered to ensure it exists / is correct?. At the moment, if an incorrect  ID is entered, the form can still be submitted, but obviously the link between the two forms will not be made.

Thanks for your help.

Try this - http://formidablepro.com/knowledgebase/formidable-hooks/frm_validate_field_entry/#kb-create-a-confirmation-field

I've taken a look through this, but the main difference is I want to validate the entry on the 2nd form against values made in the first form. The values are not set, so I can't say if [25]='this' , but instead just  if [25] exists. I have searched your help desk and found this: http://formidablepro.com/help-desk/validate-against-data-from-entry-field/

which is along the right lines, but I only need to check one field.

Thanks again

 

The link you refer to is what I use to validate a data from entry field against an input field. It sounds like what you are doing is pretty much the same, or am I missing something? You have a reference field that you want to check against with an input field, right? If you use a data from entries drop-down selection for your ID's it will only show ones that are being used.

If this isn't correct then you need to try and explain further.

Sorry if I haven't explained this very well - I'll try again:

A user ID's is generated from form 1. I want the person completing form 2  to enter a user ID in an input field and for that entry to be checked against the list of user IDs's from form 1. It just needs to check that the user ID exists. I don't want a drop down list of user ID's because that would be too long.

Any ideas? Thanks

 

 

You can do this with custom code in a new plugin or your theme functions.php. Here's an example.

add_filter('frm_validate_field_entry', 'my_custom_validation', 10, 3);
function my_custom_validation($errors, $posted_field, $posted_value){
  if($posted_field->id == 25){ //change 25 to the ID of the field to validate
    global $wpdb, $frmdb;
    //change 10 the the ID of the field in the other form that holds your user Ids
    $ids = $wpdb->get_col("SELECT meta_value FROM $frmdb->entry_metas WHERE field_id=10");
    if(!in_array($_POST['item_meta'][$posted_field->id], (array)$ids))
      $errors['field'. $posted_field->id] = 'That field is wrong!';
  }
  return $errors;
}

This is untested code. Please troubleshoot and complete on your own or with help from a developer.

Topic closed.