Contentful logo

Contentful Community

Pass search filter to MultipleEntryReferenceEditor

I want to restrict entries that can be linked in an entry further and without user input. It should be based on what entry im currently on and if that is referenced in the entry to be linked.

When clicking the “add existing content” button the MultipleEntryReferenceEditor opens with the “search for an entry” field

Target state:

How can i modify this? i have an app on Field with the following code:

  const handleClick = (sdk: FieldExtensionSDK) => {
    sdk.dialogs.selectMultipleEntries({})
    .then((arrayOfSelectedEntries) => setSelectedEntries(arrayOfSelectedEntries as Object[]));
  }

  return (
    <>
      <Button onClick={() => handleClick(props.sdk)} buttonType="primary">Add Products</Button>
      {/* <EntityList>
        {selectedEntries.map(e => {
          return <Paragraph>{JSON.stringify(e)}</Paragraph>
        })}
      </EntityList> */}

      {/* <Paragraph>Related products; {JSON.stringify(props.sdk.entry.fields)}</Paragraph> */}
      <MultipleEntryReferenceEditor
      isInitiallyDisabled={false}
      viewType="link"
      hasCardEditActions={false}
      sdk={props.sdk}
      parameters={{instance: { showCreateEntityAction: true, showLinkEntityAction: true}}}
      />
    </>
  );
};

This opens the setSelectedEntries in 2 ways. through the button or via MultipleEntryReferenceEditor. But now im lost.