I am working whith a form, in which I need to execute some ajax command on fields change.
Is working on all fields (text, taxonomy reference, entity reference...) but I am facing an issue wirh imagefield_crop.

First I added a process callback.

function MY_MODULE_field_widget_form_alter(&$element, &$form_state, $context) {
  if ((isset($element["#field_name"])) && ($element["#field_name"] == "field_image_cropped")) {
    if (isset($element[0]['#process'])) {
      $element[0]['#process'][] = 'field_image_cropped_cy_rdv_process';
    }
    $element['#process'][] = 'field_image_cropped_cy_rdv_process';
  }
}

This callback is adding a callback in the submit buttons.

function field_image_cropped_cy_rdv_process($element, $form_state, $form) {
  $element_children = element_children($element, TRUE);
  
  foreach ($element_children as $delta => $key) {
    if (($key === "remove_button") || ($key === "upload_button")) {
      $element[$key]["#submit"][] = 'ajax_check_required_fields';
    }
  }

  return $element;
}

Here is my function

function ajax_check_required_fields($form, &$form_state) {
  $commands = array();
  $commands[] = ajax_command_invoke('#check_'.$required_field, 'fadeTo', array(500, 0.2));
  $page = array('#type' => 'ajax', '#commands' => $commands);
  ajax_deliver($page);
}

When I comment out the last line ajax_deliver($page), process to crop image and add another one is working, but of course not my ajax command.
When I don't comment the last line, my ajax command is working, but the process to crop the image is not showing anymore, and I can't add another image.
Can anybody help me ?

Many thanks beforehands
Christophe

Comments

Christophe Bourgois created an issue.