Fields in drupal 7 have always the same array structure.

field_name (Array, 1 element)
  und (Array, 1 element)
     0 (Array, 3 elements) 
         value (String ) 
         safe_value (String ) 
         ....

But the country field as no value they are a good reason for that? I like to have the country object but I also nice to have a value item.

Comments

alan d.’s picture

Category: bug » feature

Country name be ok? The value field (or equivalent field) is normally the key value, which would be the iso2 value, but this is not that useful in the average site. The object is far more useful IMHO, but I could easily add this in. Take care that not all fields use the same field named 'value'.

alan d.’s picture

Status: Active » Fixed

Looking at the code the safe field contains a safe version of the country name, ready for use. Simply use this to get the name if required

johnv’s picture

Title: The field as no "value" » Normalize field values (safe -> safe_value; value)

gagarine has a point: confirming to standard structure names is easier in developing/debugging.
I have browsed other fields:
term: tid
integer: value
formattable text field: value, format, safe_value

You might consider
- renaming 'safe' to 'safe_value'
- creating 'value' (but not sure what it would contain iso2? country name?)

johnv’s picture

Status: Fixed » Active
alan d.’s picture

Status: Active » Fixed

I've committed through these additions. The value field is the ISO2 code. The safe_value parameter is just like the safe parameter, the country name passed through check_plain().

The code was updated to use the safe_value field and I expect the safe parameter to be removed in a few tags time.

Status: Fixed » Closed (fixed)

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