Uncaught TypeError: preg_match() for gform_field_value_

Hey together,

I try to fill a Listfield with entrys of another form.

add_filter( 'gform_field_value_kunde', 'my_custom_populate_dropdown' );
function my_custom_populate_dropdown( $value ) {
    // Hier die Quellformular-ID einfügen
    $source_form_id = 2;
    // Überprüfen, ob das aktuelle Formular das Zielformular ist
        // Daten aus dem Quellformular abrufen
        $source_entries = GFAPI::get_entries( 2 );
            // Dropdown-Feld mit Daten aus Quellformular füllen
    if ( ! empty( $source_entries ) ) {
        $choices = array();
        foreach ( $source_entries as $entry ) {
            // Hier den Wert und die Bezeichnung des Dropdown-Felds basierend auf den Daten aus dem Quellformular anpassen
            $key = '1';//strval(rgar($entry, 'id'));
            $label = rgar($entry, '1.6'); // Hier die Feld-ID oder den Feldnamen im Quellformular anpassen
            $choice = array ($ key => $label);
            $choices[] = $choice;
        $value = $choices;
    return $value;


I get an

Uncaught TypeError: preg_match(): Argument #2 ($subject) must be of type string, array given

What is wrong? Thanks 4 help.


There is an error in the code in this line. $ key should be $key. Does that error exist in the code you are using or only here (copy/paste error)?

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.