Well how did you need the contents of the cart stored? Will a text value do or have you got a complex object?
A simple instance of a custom form field for your case would look like
<?php
class EditableCartContentsField extends EditableFormField {
public function getFormField() {
return null;
}
public function getFieldValidationOptions() {
return false;
}
public function getValueFromData($data) {
return "This is a string to be saved into the database"
}
}
When a form with that field is saved, the getValueFromData() method will return the data to be included in the SubmittedFormField object. It can only be a string, but if you wanted to store a more complex object you can define your own subclass of SubmittedFormField and tell your object to use that instead.
public function getSubmittedFormField() {
return new CartSubmittedFormField();
}
Then your CartSubmittedFormField can store / format completely customise data.