/**
  * @param DataObjectInterface $record
  * @return $this|void
  * if ColorPicker field exists, then convert the value hex to rgb
  */
 public function saveInto(DataObjectInterface $record)
 {
     $name = $this->getName();
     if ($this->ColorPickerExists() && $record->db($name)) {
         $record->{"{$name}"} = $this->value ? 'rgb(' . implode(',', $this->hex2rgb($this->value)) . ')' : null;
     } elseif ($record->db($name)) {
         $record->{"{$name}"} = $this->value;
     }
     return $this;
 }
 /**
  * Returns all fields on the object which should be shown
  * in the output. Can be customised through {@link self::setCustomFields()}.
  *
  * @todo Allow for custom getters on the processed object (currently filtered through inheritedDatabaseFields)
  * @todo Field level permission checks
  *
  * @param DataObjectInterface|DataObject $obj
  * @return array
  */
 protected function getFieldsForObj($obj)
 {
     $dbFields = array();
     // if custom fields are specified, only select these
     if (is_array($this->customFields)) {
         foreach ($this->customFields as $fieldName) {
             // @todo Possible security risk by making methods accessible - implement field-level security
             if ($obj->hasField($fieldName) || $obj->hasMethod("get{$fieldName}")) {
                 $dbFields[$fieldName] = $fieldName;
             }
         }
     } else {
         // by default, all database fields are selected
         $dbFields = $obj->db();
     }
     if (is_array($this->customAddFields)) {
         foreach ($this->customAddFields as $fieldName) {
             // @todo Possible security risk by making methods accessible - implement field-level security
             if ($obj->hasField($fieldName) || $obj->hasMethod("get{$fieldName}")) {
                 $dbFields[$fieldName] = $fieldName;
             }
         }
     }
     // add default required fields
     $dbFields = array_merge($dbFields, array('ID' => 'Int'));
     if (is_array($this->removeFields)) {
         $dbFields = array_diff_key($dbFields, array_combine($this->removeFields, $this->removeFields));
     }
     return $dbFields;
 }