My end goal is to put the Inline Entity Form inside of a custom widget, and have it submittable without submitting the parent form inside of which it has been placed.
I'm not sure how to do this programmatically. I looked for an example in the tests/ subdirectory of IEF, and found a form like this:
$form['inline_entity_form'] = [
'#type' => 'inline_entity_form',
'#entity_type' => 'node',
'#bundle' => 'ief_test_custom',
'#form_mode' => $form_mode,
];
$form['submit'] = [
'#type' => 'submit',
'#value' => t('Save'),
];
But if I take this code and put it inside an existing form via hook_form_alter or a custom widget, it will submit the entire form, when in reality I just want it to save the values for the reference. I also tried to experiment by putting a rendered form into an iframe, but it wouldn't load the form code inside it.
$form = \Drupal::formBuilder()->getForm(\Drupal\user\Form\UserLoginForm::class);
$ief = [
'#type' => 'inline_entity_form',
'#entity_type' => 'node',
'#bundle' => 'article',
'#default_value' => \Drupal\node\Entity\Node::load(1),
'#form_mode' => 'default',
];
$element['inline_entity_form'] = [
'#type' => 'inline_template',
'#template' => '<iframe srcdoc="<div id="iframe-ief">{{ ief|escape }}</div>"></iframe>',
'#context' => [ // Tried the above with & without |escape
'ief' => $form, //<--tried both $form and $ief here.
],
];
Is there any example of doing this that I can look for, or any suggestions or which direction to look?