/** * @inheritDoc IFieldType::getInputHtml() * * @param string $name * @param mixed $criteria * * @return string */ public function getInputHtml($name, $criteria) { // Make sure the field is set to a valid category group $sourceKey = $this->getSettings()->source; if ($sourceKey) { $source = $this->getElementType()->getSource($sourceKey, 'field'); } if (empty($source)) { return '<p class="error">' . Craft::t('This field is not set to a valid category group.') . '</p>'; } return parent::getInputHtml($name, $criteria); }
/** * @inheritDoc BaseSavableComponentType::defineSettings() * * @return array */ protected function defineSettings() { return array_merge(parent::defineSettings(), array('useSingleFolder' => AttributeType::Bool, 'defaultUploadLocationSource' => AttributeType::Number, 'defaultUploadLocationSubpath' => AttributeType::String, 'singleUploadLocationSource' => AttributeType::Number, 'singleUploadLocationSubpath' => AttributeType::String, 'restrictFiles' => AttributeType::Bool, 'allowedKinds' => AttributeType::Mixed)); }
/** * @inheritDoc IFieldType::getInputHtml() * * @param string $name * @param mixed $criteria * * @return string */ public function getInputHtml($name, $criteria) { return BaseElementFieldType::getInputHtml($name, $criteria); }
/** * @inheritDoc BaseElementFieldType::getInputTemplateVariables() * * @param string $name * @param mixed $criteria * * @return array */ protected function getInputTemplateVariables($name, $criteria) { $variables = parent::getInputTemplateVariables($name, $criteria); if ($variables['sources']) { $sourceKey = $variables['sources'][0]; $source = $this->getElementType()->getSource($sourceKey, 'field'); if ($source) { $criteria = craft()->elements->getCriteria(ElementType::Category); $criteria->locale = $this->getTargetLocale(); $criteria->groupId = $source['criteria']['groupId']; $criteria->status = null; $criteria->localeEnabled = false; $criteria->limit = null; $variables['categories'] = $criteria->find(); } } $variables['selectedCategoryIds'] = $variables['elements']->ids(); return $variables; }
/** * Set settings html. * * @return array */ protected function defineSettings() { // Default settings $settings = parent::defineSettings(); // Target field setting $settings['targetField'] = AttributeType::String; // Read-only setting $settings['readOnly'] = AttributeType::Bool; // Return settings return $settings; }