When editing nodes that use location cck fields the locations in the field have 'Array' printed at the bottom.

Comments

rooby’s picture

Title: 'Array' appears at the bottom of locations for location cck fields on node edit page » 'Array' appears at the bottom of locations on node edit page

This appears to still be happening on node locations as well as cck locations.

dgastudio’s picture

same here

ankur’s picture

Status: Active » Needs review
StatusFileSize
new588 bytes

Looks like the code that builds the form array in location.module is trying to pass the location array in as the #value attribute for a fieldset.

This patch should do it.

supportPIC’s picture

Hi,

If I unset #value I got an error when saving, as if the element fields are empty.

I don't know if it is linked to this, but it seems the theme_location_element function is not called on form creation.

I am using the location_node module. Is it best to use it or the location_cck module ?

rooby’s picture

Status: Needs review » Fixed

Thanks for the patch.
Committed with the addition of a comment to explain what is going on with the unset().
http://drupal.org/cvs?commit=502310

rooby’s picture

Status: Fixed » Active

Rolled back the previous commit as it introduced a worse problem - #1067890: Location field is required.

http://drupal.org/cvs?commit=503648

enkara’s picture

Subscribing

arcaneadam’s picture

This has to do with the function theme_fieldset specifically the following lines

if (isset($element['#value'])) {
    $output .= $element['#value'];
  }

Because we add the fieldset element to the location the default theme implementation of this tries to output the $element['#value'] which in locations case is an array. I think this can be bypassed using some theming alter and #pre_render magic, but I'm not 100% yet. I'm going to try some things then post my findings and hopefully a solution.

arcaneadam’s picture

I believe I have a solution. I've added a #pre_render and #post_render function to the $element that moves the $element['#value'] prior to the fieldset rendering it and returns it to it's rightful place afterwards to make sure the form validates correctly. patch attached

arcaneadam’s picture

StatusFileSize
new3.63 KB

Whoops heres the patch

altrugon’s picture

Subscribe

TheCrow’s picture

i solved this issue just substituting on location.module (function _location_process_location()) the row:

$element += element_info('fieldset');

with the following:

  $element_info = element_info('fieldset');
  $element = array_merge($element, $element_info);
mrgoltra’s picture

StatusFileSize
new10.5 KB

Subscribing

bryancasler’s picture

Which solution should I be using #10 or #12?

tbenice’s picture

subscribing. thanks for working on this!

adaddinsane’s picture

#12 is the more elegant solution - but it doesn't work for me.

#10 works.

arcaneadam’s picture

Status: Active » Needs review

#12 isn't really a solution since it doesn't fix the problem at hand - the theme_fieldset functions handling of arrays in the #value key. Changing a + operator to array_merge doesn't change anything, they essentially work the same in this function since there are not any numbered keys to redo (look at example #3 on the PHP array_merge page)

I know my solution in #10 involves some work around but it involves the least amount of rewriting of module code, which is what I have time for right now.

bryancasler’s picture

arcaneadam, I can't get your patch in #10 to apply smoothly. I have the dev, but I don't see anything like this "function location_unimplemented_form" in location.module

I went ahead and put the "location_pre_render" at the bottom of location.module, that did work.

rlangille’s picture

I was able to successfully apply the patch in #10 to 7.x-3.x-dev on a vanilla install, and it worked like a charm. It may not be the ideal solution, but it does work.

rooby’s picture

StatusFileSize
new1.41 KB

I haven't had a chance to fully go over this but thanks for the patch.

Here is a cleaner version for latest dev.

One thing I'm not sure about without a little more investigation is in the post render function $element is being taken by reference and modified, which is not what post_render is meant for. Generally post_render is to modify the returned content variable.

Will look into it further.

joelstein’s picture

Status: Needs review » Reviewed & tested by the community

The patch in #20 works for me.

ankur’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new507 bytes

Here's another way to approach the problem.

Basically, we want to use the default location to populate the individual form elements that comprise a location. The problem we're having, however, is that the form API sets the #value attribute to be that of #default_value, our array of default values.

We want to tell the form API not to try to render this value. I noticed that custom images for buttons/submits pass a '#has_garbage_value' attribute to get around this problem. The attached patch does something similar.

joelstein’s picture

I'm not sure what #22 is doing, but it didn't remove the word "Array" from the bottom of the node form. #20 does, though.

ankur’s picture

StatusFileSize
new1.02 KB

@joelstein in #23,

Looks like you are using location_cck, for which my patch did not account.

The attached updated patch handles both location.module location forms and location_cck.module location forms.

joelstein’s picture

Status: Needs review » Reviewed & tested by the community

@ankur: Yep, and your updated patch fixed it. Thanks!

shiraz dindar’s picture

cool, is this gonna get rolled into dev soon?

rooby’s picture

I also have couple of ideas for solutions that are a little less hacky but might not work out, so i'd like to test them first and if they work out I'll post them here.
If not we can go with the current solution.

I should be all done with that in the next couple of days though.

dboulet’s picture

Patch in #24 seems to work, thanks.

Jerome F’s picture

StatusFileSize
new990 bytes

The patch in #24 removes the "array" for me too.
I'm following rooby's next step as well.

EDIT: sorry I should have named it location-1056148-29.patch

rdlang’s picture

When i did this on the latest tar in the downloads section, it dit work. After downloading the latest tree and putting that on my server, reapplying the patch in #24 did NOT remove the word array. Cleared al caches, but it's still there. Not sure if it is me or something in the tree changed

hnln’s picture

sub

Gemini-1’s picture

Subscribe -
Not sure which is best patch or what it is supposed to replace in the mod.

bryancasler’s picture

Patch #29 worked for me

dafeder’s picture

#29 worked for me.

Cybnext’s picture

Curious about the status of this patch

scorpjio’s picture

#29 worked for me too.

Jerome F’s picture

Please could you commit this?

martinpe’s picture

I second that, please commit this into your next release.

dddbbb’s picture

+1

Could really do with this being committed to 7.x-3.x-dev as soon as possible.

paulgemini’s picture

Was this committed to the release today?

mrgoltra’s picture

I don't think so. I just updated and it is still there.

gausarts’s picture

subscribing. Thanks

ankur’s picture

Status: Reviewed & tested by the community » Fixed

Committed to the 7.x-3.x branch.

To anyone that might be testing the 7.x-4.x branch, if the same issue exists there, feel free to re-open this ticket and change the "version" number on this ticket.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

DrCord’s picture

Issue summary: View changes

This patch is in the version of the module I am using [7.x-3.3] and I still am experiencing this problem.