Hello,

there is a problem with ajax calls on fields on node edit. I think its related with the widget module but i am not sure.
Here is the original issue, posted for the geoPHP module,

Only NDR (little endian) SKB format is supported at the moment

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Breakerandi’s picture

Can anybody figure out which module is the problem or which two modules can't work together?

Schnitzer’s picture

Assigned: Schnitzer » Unassigned
jasom’s picture

--

haggins’s picture

Status: Active » Needs review
FileSize
711 bytes

Here's a patch that fixes the problem for me. It basically tests if the form submission is relevant for this module and cancels further execution when it's not.

haggins’s picture

Extended the patch as there still a problem persisted when clicking on the remove button of an image field.

haggins’s picture

This one also considers upload buttons.

All in all I'd say this can be only a temporary workaround. There must be a more general solution.

mitche42’s picture

The patch didn't work for me. Somehow the leaflet widget's ajax is causing problems for the image field's ajax.

I have the same issues with the Remove/Upload buttons not working correctly on a Multiupload Imagefield (also tested with Image field).

Bug Test: In an image field on a node/add or edit form I select images to upload -> click upload -> the images show up in rows (row weight toggle link is broken/dragdrop feature broken) -> click Remove -> (page responds as if Save was clicked) -> returned to node/add or edit if there were form errors, those messages are displayed and the image field weight toggle link works again. If there weren't form errors, the node is saved and the user is redirected to that node, with the image clicked for removal not removed.

With the patch the only difference for me was after clicking Remove, the form error for the geofield isn't shown and the geofield disappears off of the page (Remove button still behaves like the Save button).

mitche42’s picture

My problem was solved with the solution from this thread (http://www.drupal.org/node/2034071)

smithmilner’s picture

FileSize
975 bytes

Definitely a problem with ajax calls on the same form. Obviously the form isn't being rebuilt correctly. I'm attaching a patch to fix the "Only NDR (little endian) SKB format is supported at the moment" issue that I'm having during ajax calls.

bennybobw’s picture

Title: Strange behaviour on node edit » Geometry type reset incorrectly on unrelated ajax calls

I'm updating the title of this issue to be more . The patch in #9 is incorrect because it will break when the ajax call actually does contain the leaflet widget values. The code in question is this:

<?php
      if (!empty($form_state['process_input'])) {
        // If the input was processed it ran through
        // leaflet_widget_process_geojson() which uses geofield_compute_values()
        // and this function returns wkb format. So adjust our parsing to avoid
        // nasty sideeffects.
        $geom_type = 'wkb';
      }
?>

which was added in commit 862fd0678 with message:

commit 862fd06789fa73e29ebacb814351f3dd6cffaed4
Author: Peter Philipp
Date: Sat Dec 6 11:25:49 2014 +0100
Form handling fix. This hopefully makes the whole thing ajax save.

bennybobw’s picture

Attaching a patch to check if the values for the field instance are in the form_state. I think this will fix the issue and keep the code that correctly changes the geometry type on relevant ajax calls. I'm not quite sure how to test it though.

bennybobw’s picture

We were having some more problems with this, so I went back and took a deeper look. The patch in #9 is correct. Here's the context. This comment is no longer true as of the latest version of the geofield module:

<?php
 if (!empty($form_state['process_input'])) {
        // If the input was processed it ran through
        // leaflet_widget_process_geojson() which uses geofield_compute_values()
        // and this function returns wkb format. So adjust our parsing to avoid
        // nasty sideeffects.
        $geom_type = 'wkb';
      }
?>

In fact geofield_compute_values calls geofield_geometry_from_values which calls geofield_get_values_from_geometry and that function returns a correct array of values that matches the field definition, not something in WKB format. So it's safe to remove the entire conditional as the patch in #9 does. I'm attaching a renamed version of the patch in #9, just so it's clear that this is the correct patch.

pixelsweatshop’s picture

Can confirm #12 fixes issue.

sano’s picture

works for me as well.
Drupal core 7.59
Leaflet 7.x-1.4
Leaflet Widget for Geofield 7.x-2.0-beta1+7-dev (2014-Dec-07)

vegardjo’s picture

+1, #12 fixed it for me as well

sano’s picture

Status: Needs review » Reviewed & tested by the community
fonant’s picture

#12 fixed an HTTP 500 error for me on the Edit form of a node with a Leaflet map widget and a multiple field_collection field that needed to use AJAX to update.