How do you get contact_id in a custom form?
Can you explain a little more what you are after in what circumstances? 

Generally speaking: when in a form Custom Data I would expect to see something like entityId or _entityID. Depending on the defintion of the custom group this would be the contact_id (or membership or activity etc.)