Here is the documentation on defaults:

return array(
  0 => array('currency' => value for currency),
  // You'll usually want to stop here. Provide more values
  // if you want your 'default value' to be multi-valued:
  1 => array('currency' => value for currency),
  2 => ...
);

This is confusing because 'value for currency' is ambiguous. Looking at the currency API, we could try (1):

array('currency' => 'USD')

or (2):

array('currency' => array('USD' => 'U.S. Dollar' (USD)'))

or (3):

array('currency' => 'U.S. Dollar' (USD)')

or even 4:

array('currency' => array('#value' => 'USD'))

The only one that doesn't throw an error is (1). On the other hand, that doesn't work: I get a NULL value from the currency dropdown in a post.

What am I doing wrong? Thanks!

Comments

shunting’s picture

Typo. #2 should read:

array('currency' => array('USD' => 'U.S. Dollar (USD)'))

(extra single quote)

shunting’s picture

Here is the value that works in the default PHP field for managing the currency field type:

return array(
0 => array('currency' => 'USD')
);

However, the drop down on the admin page does not take, nor does the dropdown when the field appears on the edit page for a post. The first value on the list, Afghanistan, always appears.