* @package taoItems */ class taoItems_actions_form_Item extends tao_actions_form_Instance { /** * (non-PHPdoc) * @see tao_actions_form_Instance::initElements() */ protected function initElements() { parent::initElements(); $elementId = tao_helpers_Uri::encode(taoItems_models_classes_ItemsService::PROPERTY_ITEM_MODEL); $ele = $this->form->getElement($elementId); $ele->feed(); $modelUri = $ele->getEvaluatedValue(); if (empty($modelUri)) { // remove deprecated models $statusProperty = new core_kernel_classes_Property(ItemModelStatus::CLASS_URI); $options = []; foreach ($ele->getOptions() as $optUri => $optLabel) { $model = new core_kernel_classes_Resource(tao_helpers_Uri::decode($optUri)); $status = $model->getOnePropertyValue($statusProperty); if (!is_null($status) && $status->getUri() != ItemModelStatus::INSTANCE_DEPRECATED) { $options[$optUri] = $optLabel; } } $ele->setOptions($options); if (count($options) === 1) { reset($options); $ele->setValue(key($options)); } } else { // replace radio with hidden element $this->form->removeElement($elementId); $itemModelElt = tao_helpers_form_FormFactory::getElement($elementId, 'Hidden'); $itemModelElt->setValue($modelUri); $this->form->addElement($itemModelElt, true); // display model label $model = new core_kernel_classes_Resource($modelUri); $itemModelLabelElt = tao_helpers_form_FormFactory::getElement('itemModelLabel', 'Label'); $itemModelLabelElt->setDescription(__('Item Model')); $itemModelLabelElt->setValue($model->getLabel()); $this->form->addElement($itemModelLabelElt, true); } } }