You are here

function simplecrop_field_attach_submit in SimpleCrop 7

Implements hook_field_attached_submit().

File

includes/simplecrop.field.inc, line 638
Contains information about field widget and related functions.

Code

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

  // If form doesn't have simplecrop widgets - nothing to process.
  if (empty($form_state['simplecrop'])) {
    return;
  }

  // Save image crops to the database.
  foreach ($form_state['simplecrop'] as $image) {

    // Ensure that submitted form contains image field processed
    // by simplecrop widget.
    if (drupal_array_get_nested_value($form, $image['parents'])) {

      // Load submitted image values.
      $value = drupal_array_get_nested_value($form_state['values'], $image['parents']);
      _simplecrop_save_crop_from_values($value);
    }
  }
}