You are here

function simplecrop_file_field_submit in SimpleCrop 7

Submit callback for image upload button. We need this to save current widget display in forms cache.

1 string reference to 'simplecrop_file_field_submit'
simplecrop_field_widget_process in includes/simplecrop.field.inc
Element #process callback for the image_image field type.

File

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

Code

function simplecrop_file_field_submit($form, &$form_state) {
  $image_parents = $form_state['triggering_element']['#parents'];

  // Remove name of triggered button.
  array_pop($image_parents);

  // Get image field value.
  $value = drupal_array_get_nested_value($form_state['values'], $image_parents);

  // If image was not uploaded, then we shouldn't switch the display.
  if (empty($value)) {
    return;
  }
  $field =& drupal_array_get_nested_value($form, $image_parents);

  // Get settings for this field instance.
  $instance = field_widget_instance($field, $form_state);
  $settings = $instance['widget']['settings']['simplecrop'];

  // Save value of current widget display.
  $form_state['simplecrop'][$value['fid']]['display'] = $settings['upload_display'];

  // Show and hide different widget fields depends on current display.
  // We need this to store actual data about displays in forms cache.
  _simplecrop_field_widget_switch_display($field, $settings['upload_display']);
}