You are here

function flag_field_attach_submit in Flag 7.2

Same name and namespace in other branches
  1. 7.3 flag.module \flag_field_attach_submit()

Implements hook_field_attach_submit().

See also

flag_field_attach_form().

File

./flag.module, line 460
The Flag module.

Code

function flag_field_attach_submit($entity_type, $entity, $form, &$form_state) {

  // This is invoked for each flag_field_attach_form(), but possibly more than
  // once for a particular form in the case that a form is showing multiple
  // entities (field collection, inline entity form). Hence we can't simply
  // assume our submitted form values are in $form_state['values']['flag'].
  if (isset($form['flag'])) {
    $parents = $form['flag']['#parents'];
    $flag_values = drupal_array_get_nested_value($form_state['values'], $parents);

    // Put the form values in the entity so flag_field_attach_save() can find
    // them. We can't call flag() here as new entities have no id yet.
    $entity->flag = $flag_values;
  }
}