After exporting and importing a node with money cck field, the default value is not shown correctly. Instead of "EUR" it is "1".

Here's the exported data:

$content[fields]  = array (
  0 => 
  array (
    'label' => 'Normal price',
    'field_name' => 'field_price_normal',
    'type' => 'money',
    'widget_type' => 'money_widget',
    'change' => 'Basisinformation ändern',
    'weight' => '-3',
    'currency_select_mode' => 'code',
    'currency_display_mode' => 'a|+|c',
    'allowed_currencies' => 
    array (
      'EUR' => true,
      0 => 1,
      'AFA' => false,
      'ALL' => false,
      'DZD' => false,
      --snip--
      --snap--
      'ZMK' => false,
      'ZWD' => false,
    ),
    'description' => 'The tickets price <b>without</b> reduction.',
    'default_value' => 
    array (
      0 => 
      array (
        'amount' => '',
        'currency' => 'EUR',
        '_error_element' => 'default_value_widget][field_price_normal][0][amount',
      ),
    ),
    'default_value_php' => '',
    'default_value_widget' => NULL,
    'group' => false,
    'required' => 1,
    'multiple' => '0',
    'precision' => '6',
    'decimals' => '2',
    'op' => 'Feldeinstellungen speichern',
    'module' => 'money',
    'widget_module' => 'money',
    'columns' => 
    array (
      'amount' => 
      array (
        'type' => 'numeric',
        'precision' => '6',
        'scale' => '2',
        'not null' => false,
        'sortable' => true,
        'views' => true,
      ),
      'currency' => 
      array (
        'type' => 'varchar',
        'length' => 3,
        'not null' => false,
        'sortable' => true,
        'views' => true,
      ),
    ),
    'display_settings' => 
    array (
      'label' => 
      array (
        'format' => 'above',
        'exclude' => 0,
      ),
      'teaser' => 
      array (
        'format' => 'default',
        'exclude' => 0,
      ),
      'full' => 
      array (
        'format' => 'default',
        'exclude' => 0,
      ),
      4 => 
      array (
        'format' => 'default',
        'exclude' => 0,
      ),
      'token' => 
      array (
        'format' => 'default',
        'exclude' => 0,
      ),
    ),
  ),
.
.
.

That seems to be allright, doesn't it?
I had a look to the database but don't realy know where default values are saved. Maybe I could find an indication where the problem lies.

Comments

haggins’s picture

note: this issue is not related to the dev-version. It happens also at the official release.

markus_petrux’s picture

I was able to reproduce this. Also noticed that the selected currencies are not reflected in the widget settings panel after importing.

I'll look into this. Thanks for the report.

markus_petrux’s picture

Status: Active » Needs review

Please, apply the following patch or wait for the next nightly snapshot. Then, update the field settings in the original field, then try exporting the type again. I believe this patch will fix the issue.

       if (function_exists('currency_api_get_currencies')) {
         $form['currencies']['#description'] .= ' '. t('The number between square brakets indicates the standard precision for each currency.');
       }
+      if (isset($widget['allowed_currencies']) && is_array($widget['allowed_currencies'])) {
+        $allowed_currencies = array_keys(array_filter($widget['allowed_currencies']));
+        $allowed_currencies = array_combine($allowed_currencies, $allowed_currencies);
+      }
+      else {
+        $allowed_currencies = array();
+      }
       $form['currencies']['allowed_currencies'] = array(
         '#type' => 'checkboxes',
         '#options' => $currency_options,
-        '#default_value' => (isset($widget['allowed_currencies']) && is_array($widget['allowed_currencies']) ? $widget['allowed_currencies'] : array()),
+        '#default_value' => $allowed_currencies,
         '#checkall' => TRUE,
         '#prefix' => '<div class="money-field-currency-checkboxes">', '#suffix' => '</div>',
       );
haggins’s picture

Thanks for the patch. Unfortunately it doesn't change anything.

I created a new node type with an extra money field and exported it. Then I deleted the node type and created it again without money field. By importing the exported data the field was automatically created. Default currency value is still '1'.

markus_petrux’s picture

hmm... I have committed a small change to CVS. It will be available in the next nightly snapshot. Hope that fixes the issue.

markus_petrux’s picture

Status: Needs review » Fixed

Please, re-open if it doesn't fixe the problem.

Status: Fixed » Closed (fixed)

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