You are here

public function FlexiformBuilderFlexiform::formSubmit in Flexiform 7

Submit the form.

Overrides FlexiformBuilder::formSubmit

File

includes/builder/flexiform.builder.inc, line 177
Contains the FlexiformBuilderFlexiform Class

Class

FlexiformBuilderFlexiform
Flexiform Builder Class for the complex flexiforms.

Code

public function formSubmit($form, &$form_state, $save = TRUE) {
  $flexiform_state =& $this
    ->getFlexiformState($form, $form_state);
  foreach (element_children($form) as $element_namespace) {
    if (empty($form[$element_namespace]['#flexiform_element'])) {
      continue;
    }
    $element = $form[$element_namespace]['#flexiform_element'];
    $entity = $this
      ->getFormEntity($element
      ->getEntityNamespace(), $flexiform_state);
    $element
      ->formSubmit($form, $form_state, $entity);
  }
  $this
    ->invoke($form, $form_state, 'submit');
  if ($save) {
    $this
      ->save($this
      ->getEntityManager($flexiform_state), $form_state);
  }
  $this
    ->setFlexiformState($form, $form_state);
}