Custom Field Type with Multiple Values
You can do this simply by setting your field type’s defineContentAttribute() method to return AttributeType::Mixed, which will tell Craft to JSON-encode its value before storing it in the database.



public function defineContentAttribute()
{
    return AttributeType::Mixed;
}


Then, whatever you submit in the field’s post data will be saved as-is.

For example, if your getInputHtml() method had this:

public function getInputHtml($name, $value)
{
    $lat = (isset($value['lat']) ? $value['lat'] : '');
    $lng = (isset($value['lng']) ? $value['lng'] : '');

    return '&lt;input type="text" name="'.$name.'[lat]" value="'.$lat.'"&gt;' .
           '&lt;input type="text" name="'.$name.'[lng]" value="'.$lng.'"&gt;';
}


Then it would be expected that the resulting post data for your field would look something like:

array(
    'lat' =&gt; '12345',
    'lng' =&gt; '67890'
)


And with AttributeType::Mixed, that’s exactly how it would get stored. Behind the scenes it will get JSON-encoded when getting saved to the DB, and JSON-decoded when getting fetched from the DB, but your field type will never need to know about that.