You are here

function editableviews_handler_field_field_edit::edit_form_submit in Editable Views 7

Handle the form submission for this field's form element.

File

handlers/editableviews_handler_field_field_edit.inc, line 229

Class

editableviews_handler_field_field_edit
Field handler for toggling between rendered value and edit form element.

Code

function edit_form_submit($entity_type, $entity, &$element, &$form_state) {
  list($entity_id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
  $field_name = $this->definition['field_name'];
  $field_instance = field_info_instance($entity_type, $field_name, $bundle);

  // Because a View result can show entities of different bundles, it is
  // essential that we check the field actually exists on the current entity.
  // ctools_field_invoke_field() does actually check for this too, but that
  // only works when it's passed a field name rather than a whole instance.
  if (empty($field_instance)) {
    return;
  }

  // Extract field values from submitted values.
  // We pass the partial $form array to the Field API hook. This contains at
  // its base the #parents array, which tells Field API where to look for
  // the values in $form_state.
  ctools_field_invoke_field_default($field_instance, 'extract_form_values', $entity_type, $entity, $element, $form_state);
  ctools_field_invoke_field_default($field_instance, 'submit', $entity_type, $entity, $element, $form_state);
}