Forgive my submitting two bug reports in as many minutes.

As I said in my previous issue (http://drupal.org/node/347091) I have an event content type and I'm trying to attach a location to it. The CCK field type isn't working (see the other bug report) so I tried the non-CCK Location field which seemed to work except when previewing content.

I have preview turned on and required for my event type content and, when previewing, the Location fields empty themselves.

The data shows up in the preview, but the fields on the form are empty, so when the content is saved, it's saved with those empty fields and therefore loses location information.

Please let me know if there's anything I can try to fix it.

CommentFileSizeAuthor
#6 location_preview_additional.patch655 bytesroderik

Comments

FoolsRun’s picture

Priority: Normal » Critical

I can, after testing, confirm that if you don't preview the content, the location is stored correctly. In preview the form fields do not re-populate with the previewed data and therefore, when the form is posted, it's saved with empty location fields.

This is kinda critical, I think.

bdragon’s picture

Hmm, I was just able to reproduce.

bdragon’s picture

Status: Active » Postponed (maintainer needs more info)

Should be fixed now, in commits http://drupal.org/cvs?commit=159098 thru http://drupal.org/cvs?commit=159101.

I'm not sure whether or not the patch is needed on D5.

yesct’s picture

Status: Postponed (maintainer needs more info) » Fixed

no-one seemed to need this for D5, marking fixed.

Status: Fixed » Closed (fixed)

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

roderik’s picture

Version: 6.x-3.0 » 6.x-3.x-dev
Status: Closed (fixed) » Needs review
StatusFileSize
new655 bytes

Seems you forgot to patch the 'hack for the "additional" field' a few lines below.

That still shows empty (and/or 'previous saved value') on preview.

SeanBannister’s picture

Assigned: Unassigned » SeanBannister
Status: Needs review » Reviewed & tested by the community

Looks good, I'll commit this soon.

bdragon’s picture

Status: Reviewed & tested by the community » Closed (duplicate)

This was just fixed in a different way over in #441272: Additional - do not collect doesn't respect setting.

buzzman’s picture

With bdragon's commit in #3 and #8 everything worx fine except Location Autocomplete field, which still clears on Preview in Node Edit form (when it already has a value).

For anyone having the same issue and who needs to keep their hair where it's at ;-), how I fixed it in location.module is like this:

function location_locationapi(&$obj, $op, $a3 = NULL, $a4 = NULL, $a5 = NULL) {
        case 'province':
.
.
.
		  return array(
.
.
.
            '#value' => $obj, // changed from '#default_value'
.
.
.

and now the autocomplete value happily persists in Preview.

cheers.

buzzman’s picture

oops, posted too soon!

actually, this needs to be inside a condition like below as otherwise, for new user registration the $obj is blank and that causes the Province to go in with a "" value:

function location_locationapi(&$obj, $op, $a3 = NULL, $a4 = NULL, $a5 = NULL) {
.
.
.
        case 'province':
.
.
.
  return array(
.
.
.
          if (arg(0) == "user" && arg(1) == "register") {
              return array(
              '#type' => 'textfield',
              '#title' => t('State/Province'),
              '#autocomplete_path' => 'location/autocomplete/'. $country,
              '#default_value' => $obj,
              '#size' => 64,
              '#maxlength' => 64,
              '#description' => NULL,
              // Used by province autocompletion js.
              '#attributes' => array('class' => 'location_auto_province'),
              '#required' => ($a4 == 2),
            );
          } else {
              return array(
              '#type' => 'textfield',
              '#title' => t('State/Province'),
              '#autocomplete_path' => 'location/autocomplete/'. $country,
              '#value' => $obj,
              '#size' => 64,
              '#maxlength' => 64,
              '#description' => NULL,
              // Used by province autocompletion js.
              '#attributes' => array('class' => 'location_auto_province'),
              '#required' => ($a4 == 2),
            );
          }
.
.
.

I'm sure there is a better way, but I needed it quick and this worx gr8.

cheers.