/** * @return PropertyInputInterface */ public function input() { $prop = $this->prop(); /** @todo Needs fix. Must be manually triggered after setting data for metadata to work */ $metadata = $prop->metadata(); $inputType = $this->inputType(); $this->input = $this->propertyInputFactory()->create($inputType); $this->input->setInputType($inputType); $this->input->setProperty($prop); $this->input->setPropertyVal($this->propertyVal); $this->input->setData($prop->data()); $this->input->setViewController($this->viewController()); if (isset($metadata['admin'])) { $this->input->setData($metadata['admin']); } $GLOBALS['widget_template'] = $inputType; $res = []; if ($this->loopL10n() && $prop->l10n()) { $langs = $this->availableLanguages(); $inputId = $this->input->inputId(); foreach ($langs as $lang) { // Set a unique input ID for language. $this->input->setInputId($inputId . '_' . $lang); $this->input->setLang($lang); (yield $this->input); } } else { (yield $this->input); } }
/** * Setup the property's display value before its assigned to the object row. * * This method is useful for classes using this trait. * * @param ModelInterface $object The current row's object. * @param PropertyInterface $property The current property. * @return void */ protected function setupDisplayPropertyValue(ModelInterface $object, PropertyInterface $property) { $displayType = $property->displayType(); $this->display = $this->propertyDisplayFactory()->create($displayType); $this->display->setDisplayType($displayType); $this->display->setProperty($property); $metadata = $property->metadata(); $objMetadata = $object->metadata()->property($property->ident()); if ($objMetadata) { $metadata->setData($objMetadata); } $this->display->setData($metadata); $this->display->setData($property->viewOptions($displayType)); }