Hello,

thanks for the work! Loving this module.

Steps to reproduce:

1. Create 2 content types
2. Make one content type reference the other using entity reference
3. Go to the reference field's "Manage Form Display" Page and select "Inline entity form - Single value" and save.
4. Go ahead and create a node of the referencing content type.
5. Notice that no reference field widget is displayed.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

webiator GmbH’s picture

Issue summary: View changes
woprrr’s picture

Yep ! I confirm this !! Inline_entity_form work only in multiple value mode.

I'll take a look this. I suspect a problem in retrieving form elements.

woprrr’s picture

OK !! It's "normal"

The function formElement() is not set in InlineEntityFormSingle class.

  /**
   * {@inheritdoc}
   */
  public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) {
    $ief_id = $this->fieldDefinition;

    return $element;
  }

I think this issue join this https://www.drupal.org/node/2489230.

Because the contents of the form will be the same in the end. It does not just have the opportunity to set a higher value 1 in the setting of the widget. And this is already the case in the configuration

 * @FieldWidget(
 *   id = "inline_entity_form_single",
 *   label = @Translation("Inline entity form - Single value"),
 *   field_types = {
 *     "entity_reference"
 *   },
 *   settings = {
 *     "allow_existing" = FALSE,
 *     "match_operator" = "CONTAINS",
 *     "delete_references" = FALSE,
 *     "override_labels" = FALSE,
 *     "label_singular" = "",
 *     "label_plural" = ""
 *   },
 *   multiple_values = false <------ See this
 * )

The final definition of the elements will be the same as multiple I think. (Feel free to tell me if I'm wrong).

--------Test------
Apply the test patch file in this issue, Singlewidget does works.

Conclusion !

It is not the fix for this issue, but an example. We must define what should be displayed in the single case or not . Single and Multiple define whether have the same form Elements or if the configuration widget which prevents add more items ?

It takes little thinking be if two widgets are still useful in the sense that with multiple it is possible to make a widget set has one value, it becomes a single one ... Make widget also solves the issue of refactoring that I ' I propose to the other end and simplifies the structure !

I wait your reactions :)

woprrr’s picture

woprrr’s picture

Status: Active » Needs review
woprrr’s picture

FileSize
58.42 KB

Reload the patch with last version of IEF.

webiator GmbH’s picture

The widget is now the same as for multiple values widget. The patch works though

woprrr’s picture

Status: Needs review » Closed (won't fix)

Close the benefit of a more suitable outcome @see https://www.drupal.org/node/2491527#comment-9940087

I need you brutzelspeck :)

Thanks for your job .