/**
  * Get the list of extra data from the $record as saved into it by
  * {@see Form::saveInto()}
  *
  * Handles detection of falsey values explicitly saved into the
  * DataObject by formfields
  *
  * @param DataObject $record
  * @param SS_List $list
  * @return array List of data to write to the relation
  */
 protected function getExtraSavedData($record, $list)
 {
     // Skip extra data if not ManyManyList
     if (!$list instanceof ManyManyList) {
         return null;
     }
     $data = array();
     foreach ($list->getExtraFields() as $field => $dbSpec) {
         $savedField = "ManyMany[{$field}]";
         if ($record->hasField($savedField)) {
             $data[$field] = $record->getField($savedField);
         }
     }
     return $data;
 }
 /**
  * Gets the table which contains the sort field.
  *
  * @param DataList $list
  * @return string
  */
 public function getSortTable(SS_List $list)
 {
     $field = $this->getSortField();
     if ($list instanceof ManyManyList) {
         $extra = $list->getExtraFields();
         $table = $list->getJoinTable();
         if ($extra && array_key_exists($field, $extra)) {
             return $table;
         }
     }
     $classes = ClassInfo::dataClassesFor($list->dataClass());
     foreach ($classes as $class) {
         if (singleton($class)->hasOwnTableDatabaseField($field)) {
             return $class;
         }
     }
     throw new Exception("Couldn't find the sort field '{$field}'");
 }