Allow inline entity form submit handler to return the saved entity

Created on 26 September 2018, about 6 years ago
Updated 9 December 2023, 11 months ago

I'm embedding an inline_entity_form widget into a Drupal Commerce pane form like so:


  public function buildPaneForm(array $pane_form, FormStateInterface $form_state, array &$complete_form) {
    $pane_form['ief'] = [
      '#type' => 'inline_entity_form',
      '#entity_type' => 'my_entity',
      '#bundle' => 'my_bundle',
      '#default_value' => NULL,
    ];
  }

In my submit handler, I'm doing the following:


  public function submitPaneForm(array &$pane_form, FormStateInterface $form_state, array &$complete_form) {
      InlineEntityForm::submitEntityForm($pane_form, $form_state);
  }

This works well and saves the entities, but is there a better way to do this? I'd like to get the IDs of the entities that have been saved and the submit handler obviously doesn't return anything.

✨ Feature request
Status

Needs review

Version

3.0

Component

Code

Created by

πŸ‡¬πŸ‡§United Kingdom jamiehollern Alba/Scotland

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024