- Issue created by @sirir
- Status changed to Fixed
about 1 year ago 10:36am 6 December 2023 Automatically closed - issue fixed for 2 weeks with no activity.
I'm trying to figure out how ief works...
I have a parent entity which contains some ief simple and ief complex in the same page. I have a button that does an submit ajax callback, i notice that $form_state->getValues() contain the values from ief that I want on my entity but I didn't find a way to get my values from my ief to my entity in AJAX.
The only thing that could work for me is by using something like this by hand :
$form_ief = $form["main_product"]["widget"][0]['inline_entity_form'];
InlineEntityForm::submitEntityForm($form_ief, $form_state);
$form_ief = $form["main_product"]["widget"][0]['inline_entity_form']["product_options"]["widget"][0]['inline_entity_form'];
InlineEntityForm::submitEntityForm($form_ief, $form_state);
// My entity now contains the ief values
$entity = $form_state->getFormObject()->getEntity();
// I have business logic that depends on my $entity and ief values ...
\Drupal::service('business_logic')->execute($entity->get('product_options'));
$form_ief_complex = ???
// How to submit all ief forms programmatically and get rebuild the entity with my values ?
}
The problem is my entity can contain nested IEFs and complex IEFs. But I get stuck I cloudn't make it work...
Is there a simpler way to submit the form in ajax and rebuild the entity with ief values ?
By the way when I don't use ajax to submit the form everything works as expected. But need it to work in ajax :(
I thank you in advance
R.
Fixed
Code
Automatically closed - issue fixed for 2 weeks with no activity.