Reader Interactions

Leave a Reply

Your email address will not be published. Required fields are marked *

Comments

    • The $where clause is your filter, but you need to examine the SQL statement as Formidable generates it when $meta= true. That’s the only way to know the alias Formidable gives to frm_item_metas in the LEFT JOIN.

      You can also filter after the fact by looping through the associative array and filtering it by the meta value.

  1. Looks like I’m lost here trying to filter a lookup field in Form A, from a data in Form B.

    Using FrmEntry::getAll(), I’m trying to fetch all entries from form B. Don’t know if I’m doing this right or there’s a better approach?

    add_filter(‘frm_setup_new_fields_vars’, ‘filter_lookup_options_for_returned_cylinders’, 20, 2);
    add_filter(‘frm_setup_edit_fields_vars’, ‘filter_lookup_options_for_returned_cylinders’, 20, 2);

    function filter_lookup_options_for_returned_cylinders($values, $field){
    if($field->id == ‘LookupFieldID’){ // Replace ‘LookupFieldID’ with the actual ID of your lookup field in Form A
    $filtered_options = array();

    //Fetching all entries from Form B
    $entries = FrmEntry::get_all( array(), ”, ”, true, false);

    foreach($entries as $entry){
    $entry_values = maybe_unserialize($entry->metas);
    if(isset($entry_values[‘StatusFieldID’]) && $entry_values[‘StatusFieldID’] == ‘Returned’){ // Replace ‘StatusFieldID’ with the ID of your status field in Form B
    // Add only “Returned” cylinders to options
    if(isset($entry_values[‘CylinderNumberFieldID’])){ // Replace ‘CylinderNumberFieldID’ with the ID of cylinder # field in Form B
    $filtered_options[$entry->id] = $entry_values[‘CylinderNumberFieldID’];
    }
    }
    }

    // Override the lookup field options
    $values[‘options’] = $filtered_options;
    }

    return $values;
    }

  2. Thank you a lot for this article!

    Is there a way to sort by multiple strings like ‘meta_1854 ASC, meta_254 DESC’