2

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

enter image description here

  • Actually it allows me to create a new node of ANY content type.However,I want to be able to create a specific content type,the one that the view uses. – sokratis Mar 13 '15 at 15:18
0

Try editing the inline entity field and only setting one entity (ie Company content type in your example) that can be referenced.

| improve this answer | |
0

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']);
    }
}
| improve this answer | |
  • I'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) – JonMcL Apr 3 '19 at 20:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.