I am using Inline entity form for a non-commerce project. The settings are:Widget:multiple values,Node:Allow users to add existing content. Mode:Views:Filter by Entity reference view.So I have created an Entity reference view to show only nodes that have been created by the user. The issue is:When looking at the Inline entity form to create or add existing content,there is a dropdown with all the content types of the site.This only appeared when I change the mode to Views:Filter by Entity reference view How can I remove that? thanks See image attached
2 Answers
Try editing the inline entity field and only setting one entity (ie Company content type in your example) that can be referenced.
I managed to solve this by making changes to inline_entity_form.module specifically the inline_entity_form_settings function. This fix requires you to have already selected the target bundle in the ief tables module and limits to only one content type (I'm sure someone can easily adapt this logic to include multiple by adding a separate settings option).
After the line
// Allow other modules to alter the settings.
drupal_alter('inline_entity_form_settings', $settings, $field, $instance);
add in the following code:
if (empty($settings['bundles']) && isset($instance['widget']['settings']['type_settings']['ief_table_view_mode']['bundles'])) {
if (array_search('1', $instance['widget']['settings']['type_settings']['ief_table_view_mode']['bundles']) != false) {
$settings['bundles'][] = array_search('1', $instance['widget']['settings']['type_settings']['ief_table_view_mode']['bundles']);
}
}
-
1I'd like to point out that modifying a contributed module's code is not the right way to handle a situation like this. You should instead be adding a custom module that implements the hook offered by that call to drupal_alter. So, if your custom module is named 'custommodule', you would have a function like: function custommodule_inline_entity_form_setttings_alter($settings, $field, $instance)– JonMcLCommented Apr 3, 2019 at 20:30