You are here

function inline_entity_form_close_child_forms in Inline Entity Form 7

Button #submit callback: Closes all open child forms in the IEF widget.

Used to ensure that forms in nested IEF widgets are properly closed when a parent IEF's form gets submitted or cancelled.

1 string reference to 'inline_entity_form_close_child_forms'
inline_entity_form_entity_form in ./inline_entity_form.module
Wraps and returns the entity form provided by the passed-in controller.

File

./inline_entity_form.module, line 1414
Provides a widget for inline management (creation, modification, removal) of referenced entities. The primary use case is the parent -> children one (for example, order -> line items), where the child entities are never managed outside the…

Code

function inline_entity_form_close_child_forms($form, &$form_state) {
  $element = inline_entity_form_get_element($form, $form_state);
  foreach (element_children($element) as $key) {
    if (!empty($element[$key])) {
      inline_entity_form_close_all_forms($element[$key], $form_state);
    }
  }
}