I upgraded from 1.0 to 1.1. Now I get the following error when trying to edit a field in my view's block display:

An AJAX HTTP error occurred.
HTTP Result Code: 200
Debugging information follows.
Path: /admin/structure/views/ajax/config-item/locations/block_1/field/field_geocoded_address
StatusText: parsererror
ResponseText: 
Fatal error:  Unsupported operand types in /var/www/oppstarget/includes/form.inc on line 2637

At the same time I have a few interesting messages in watchdog:

442  30/Jan 17:06  php       warning   Warning: array_merge() [function.array-merge]: Argument #2 is
                                        not an array in leaflet_form_elements() (line 591 of
                                        /var/www/oppstarget/sites/all/modules/contrib/leaflet/leaflet.f
                                        ormatters.
 441  30/Jan 17:06  php       notice    Notice: Undefined variable: field_options in
                                        leaflet_field_formatter_settings_form() (line 109 of
                                        /var/www/oppstarget/sites/all/modules/contrib/leaflet/leaflet.f
                                        ormatters.inc).
 440  30/Jan 17:06  php       warning   Warning: Invalid argument supplied for foreach() in
                                        leaflet_field_formatter_settings_form() (line 103 of
                                        /var/www/oppstarget/sites/all/modules/contrib/leaflet/leaflet.f
                                        ormatters.inc).
 439  30/Jan 17:06  php       notice    Notice: Undefined index: #fields in
                                        leaflet_field_formatter_settings_form() (line 103 of
                                        /var/www/oppstarget/sites/all/modules/contrib/leaflet/leaflet.f
                                        ormatters.inc).

The field in question is geocoded from another field. It works fine if I create a new view, add the relevant fields, and set the formatter to this field to something like Latitude/Longitude or WKT. As soon as I try and select the Leaflet formatter, I get the popup box with the Ajax error and then I'm unable to change it back. This is stopping me from upgrading from 1.0 unfortunately so I'd appreciate any ideas.

Using:
- Drupal 7.26
- Leaflet 1.1
- Leaflet library 0.7
- Geofield 2.1
- Addressfield 1.0-beta5
- Geocoder 1.2

Issue fork leaflet-2185767

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

cboyden’s picture

I am seeing this same error when trying to apply settings to a Leaflet-formatted Geofield with Panels and Panelizer.

An AJAX HTTP error occurred.
HTTP Result Code: 200
Debugging information follows.
Path: /panels/ajax/editor/edit-pane/panelizer%3Adefault%3Anode%3Aproject.page_manager%3Adefault/87/step1
StatusText: OK
ResponseText: 
Fatal error:  Unsupported operand types in /www/mapsite/includes/form.inc on line 2637

And I am also seeing the exact same messages in the watchdog as markgifford.

Modules:
leaflet-7.x-1.1+1-dev
leaflet_markercluster-7.x-1.0-beta1+6-dev
panels-7.x-3.2+5-dev
panelizer-7.x-3.0-rc1
geofield-7.x-2.1

Libraries:
Leaflet 0.7.2
Latest version of Leaflet.markercluster

Freaka’s picture

Hey,

Same error here and it's when I try to update a field in a view too :

StatusText: OK
ResponseText : 
Fatal error:  Unsupported operand types in (..)/form.inc on line 2630
markgifford’s picture

I had a bit of time to dig into this finally. It looks like the bug was introduced in this commit: http://drupalcode.org/project/leaflet.git/blobdiff/0f89272cd5aca5bbfea03...

The addition of '#empty_option' => t('-- Select --'), to the "Marker Field" select element is a definite UI improvement when you're formatting the field directly attached to a node but it's what seems to be breaking things when the field formatter is being accessed in Views. Removing this line fixes things for me temporarily, and I'm able to use the latest dev.

Looking at the relevant docs for Form API (https://api.drupal.org/api/drupal/developer!topics!forms_api_reference.h...), it says that use of this property depends on quite a few things related to the several possible #states of the select field. The states don't appear to be working correctly in Views UI at all (see screenshots), and I wonder if this is the real reason the addition of #empty_option broke the site. It was only when I accessed the field_formatter attached to a node that I noticed parts of the form are supposed to become visible and invisible depending on whether you select "Icon File" or "Field (html DivIcon)"

markgifford’s picture

halloffame’s picture

+1 to this. Commented out #empty_option bit fixed the problem.

briand44’s picture

Status: Active » Needs review
StatusFileSize
new14 KB

I think the reason the #empty_option is causing problems is not because of the #states not working but because #options is NULL in views ui and panels/page manager ui. Here is an attempt at a patch that just sets the select list options to an empty array in this case. We should figure out the correct way to set #options in these instances but for now this should get rid of the error. This patch also addresses the #states issue as well.

markgifford’s picture

+1. I just applied the patch to latest dev. Patch applied cleanly, and seems to have fixed the issue. See screenshots. Thanks briand44

vlooivlerke’s picture

Thanks, the patch in #6 works

bneil’s picture

Status: Needs review » Reviewed & tested by the community

Setting to RTBC based on comments in #7, #8 and I have also tested the patch.

socialnicheguru’s picture

this works. RTBC

juzzuu’s picture

After 3 days of trying to make this work in Panels and Views, yes! Many thanks. The patch in #6 works great.

miromarchi’s picture

Title: Leaflet field formatter errors when trying to edit geocoded field in view » Leaflet field formatter errors when trying to edit geocoded field in view or panel

I added "panel" to the title for issue search improvement. #6 works for me too, thanks!

Helrunar’s picture

Patch in #6 works fine for me.

Helrunar’s picture

Patch in #6 is working fine for me, too.

nattyweb’s picture

Great stuff - #6 worked for me; used on current dev version of Leaflet (7.x-1.x-dev, 2014-Oct-05). Thank you and please can we get this committed to save others having to hunt down the problem?!

sja1’s picture

Patch #6 fixed the problem for me.

ergophobe’s picture

Number 6 fixed this issue for me as well.

barwonhack’s picture

Kudos and thanks for Patch #6.

Perhaps a module maintainer could commit release?

jweirather’s picture

Yes, kudos and thank you for the clear (keyword rich, top search result) documentation of the error, and for the fix.

The patch in #6 worked beautifully for me.

Applied patch and reflexively cleared cache.

MatthewHager’s picture

Patch is working for us.

n20’s picture

#6 worked for me initially. For some reason notices and warnings came back:

Notice: Undefined index: #fields in leaflet_field_formatter_settings_form() (line 103 of...
Warning: Invalid argument supplied for foreach() in leaflet_field_formatter_settings_form() (line 103...
Notice: Undefined variable: field_options in leaflet_field_formatter_settings_form() (line 109...

i looked at $form and there is no $form['#fields']:

... (Array, 5 elements)

    buttons (Array, 5 elements)
        #type (String, 7 characters ) actions
        #weight (Integer) 1000
        previous (Array, 8 elements)
            #type (String, 6 characters ) submit
            #value (String, 4 characters ) Back
            #next (String, 5 characters ) step1
            #wizard type (String, 4 characters ) next | (Callback) next();
            #weight (Integer) -2000
            #limit_validation_errors (Array, 0 elements)
            #submit (Array, 1 element)
                0 (String, 20 characters ) ctools_wizard_submit | (Callback) ctools_wizard_submit();
            #attributes (Array, 0 elements)
        return (Array, 4 elements)
            #type (String, 6 characters ) submit
            #value (String, 6 characters ) Finish
            #wizard type (String, 6 characters ) finish
            #attributes (Array, 0 elements)
        cancel (Array, 6 elements)
    #validate (Array, 0 elements)
    #submit (Array, 2 elements)
        0 (String, 56 characters ) ctools_entity_field_content_type_formatter_styl... | (Callback) ctools_entity_field_content_type_formatter_styl...();
            ctools_entity_field_content_type_formatter_styles_submit
        1 (String, 20 characters ) ctools_wizard_submit | (Callback) ctools_wizard_submit();
    #action (String, 104 characters ) /panels/ajax/editor/edit-pane/panel_context%3An...
        /panels/ajax/editor/edit-pane/panel_context%3Anode_view%3A%3Anode_view_panel_context%3A%3A%3A%3A/5/step2
    ctools_field_list (Array, 2 elements)
        #type (String, 5 characters ) value
        #value (Array, 0 elements)

astringer’s picture

The patch cleared the ajax error for me, but I'm getting the same errors as N20 above. Is this the same issue the patch in #6 addressed?

barwonhack’s picture

Switch to ip_geoloc module.

astringer’s picture

Thanks, adding the ip_geoloc module fixed it.

rdeboer’s picture

Yay :-)

guypaddock’s picture

#6 worked for me.

socialnicheguru’s picture

Does this fix issue solve this:
https://www.drupal.org/node/1796656

nwom’s picture

Status: Reviewed & tested by the community » Closed (duplicate)
Related issues: +#1796656: Selecting Leaflet field formatter in a Leaflet Map Views display breaks things greatly

The newest dev includes #1796656: Selecting Leaflet field formatter in a Leaflet Map Views display breaks things greatly, which fixes this issue as well. The patch in this thread is no longer needed.

I tested by first applying the patch in this thread using the prior dev, which solved the issue. Then I used the newest dev, and this patch was no longer necessary.

I'm fairly certain that we can close this thread.

nwom’s picture

Version: 7.x-1.1 » 7.x-1.x-dev
rdeboer’s picture

Thanks for confirming @NWOM.
Gives us confidence about making dev the new official release.
Rik

vagelis-prokopiou’s picture

I had the same issue in views, and I 'solved' it by using another formatter, that is 'Geofield Map'. There is a module with the same name that you must enable first.

pyxio’s picture

this issue appears to be back in 7.x-1.4 and 7.x-1.x-dev

gemp’s picture

It's back in 7.x-1.4 (dev is identical). It doesn't cause Ajax havoc but no option set on the marker is taken into account.

Errors in the log for leaflet.formatters.inc:

Notice: Undefined variable: field_options in leaflet_field_formatter_settings_form() line 109
Warning: Invalid argument supplied for foreach() in leaflet_field_formatter_settings_form() line 103
Notice: Undefined index: #fields in leaflet_field_formatter_settings_form() line 103

I applied the #6 patch (to no avail), so line numbers may vary.

Drupal 7.59
Views 7.x-3.20

DCLoganGuy made their first commit to this issue’s fork.