- πΊπΈUnited States dcam
Due to limited developer time old feature requests for IEF are being closed. If you still have a need for this functionality, then you may feel free to reopen the issue.
I'd like to refer to #2855769: Prepopulate entity in D8 β which shows a way to prepopulate entities through a form alter. The conclusion of the issue was the following:
There's definitely room for improvement, so perhaps a separate feature request is due.
This is that separate issue :-) I'm willing to provide a patch for this, but first would like to know the direction we should go at.
In Drupal\inline_entity_form\Element\InlineEntityForm::processEntityForm()
there's the following piece of code:
// This is an add operation, create a new entity.
$entity_type = \Drupal::entityTypeManager()->getDefinition($entity_form['#entity_type']);
$storage = \Drupal::entityTypeManager()->getStorage($entity_form['#entity_type']);
$values = [];
if ($langcode_key = $entity_type->getKey('langcode')) {
if (!empty($entity_form['#langcode'])) {
$values[$langcode_key] = $entity_form['#langcode'];
}
}
if ($bundle_key = $entity_type->getKey('bundle')) {
$values[$bundle_key] = $entity_form['#bundle'];
}
$entity_form['#entity'] = $storage->create($values);
Allowing modules to alter the $values array right before passing it to the entity storage handler looks to me like an elegant solution? The alter hook would provide some context, for example the $form_state and $complete_form.
Closed: won't fix
1.0
Code
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.
Due to limited developer time old feature requests for IEF are being closed. If you still have a need for this functionality, then you may feel free to reopen the issue.