/** * Prep value for CP. * * @param mixed $value * * @return mixed */ private function prepValueForCp($value) { // Overwrite value, if any if ($value) { // Unset value $value = null; // Fetch target id(s) $results = craft()->db->createCommand()->select('targetId')->from('relations')->where(array('fieldId' => $this->model->id, 'sourceId' => $this->element->id))->queryAll(); // If db result is valid if ($results && is_array($results)) { // Gather value $value = array(); // Loop through target ids foreach ($results as $result) { $value[] = $result['targetId']; } } } // Return with new values return parent::prepValue($value); }
/** * Limit filekinds to video only. * * @return array */ protected function defineSettings() { return array_merge(parent::defineSettings(), array('restrictFiles' => array(AttributeType::Bool, 'default' => true), 'allowedKinds' => array(AttributeType::Mixed, 'default' => array('video')))); }