*/ class BsSetFieldRenderer extends BsFieldRenderer { /** * @inheritDoc */ public function Render() { $oOutput = parent::Render(); $sFieldMandatoryClass = ($this->oField->GetMandatory()) ? 'form_mandatory' : ''; $sFieldDescriptionForHTMLTag = ($this->oField->HasDescription()) ? 'data-tooltip-content="'.utils::HtmlEntities($this->oField->GetDescription()).'"' : ''; // Vars to build the table // $sAttributesToDisplayAsJson = json_encode($this->oField->GetAttributesToDisplay()); // $sAttCodesToDisplayAsJson = json_encode($this->oField->GetAttributesToDisplay(true)); // $aItems = array(); // $aItemIds = array(); // $this->PrepareItems($aItems, $aItemIds); // $sItemsAsJson = json_encode($aItems); // $sItemIdsAsJson = htmlentities(json_encode(array('current' => $aItemIds)), ENT_QUOTES, 'UTF-8'); // Rendering field if (!$this->oField->GetHidden()) { /** @var \ormSet $oOrmItemSet */ $oOrmItemSet = $this->oField->GetCurrentValue(); // Opening container $oOutput->AddHtml('
'); // Label $oOutput->AddHtml('
'); if ($this->oField->GetLabel() !== '') { $oOutput->AddHtml(''); } $oOutput->AddHtml('
'); // Value $oOutput->AddHtml('
'); // ... in edit mode if(!$this->oField->GetReadOnly()) { $oAttDef = MetaModel::GetAttributeDef($oOrmItemSet->GetClass(), $oOrmItemSet->GetAttCode()); $sJSONForWidget = $oAttDef->GetJsonForWidget($oOrmItemSet); // - Help block $oOutput->AddHtml('
'); // - Value regarding the field type $oOutput->AddHtml(''); // Attaching JS widget only if field is hidden or NOT read only // JS Form field widget construct $aValidators = array(); $sValidators = json_encode($aValidators); $oOutput->AddJs( <<oField->GetGlobalId()}').val(); return value; }, }); EOF ); } // ... in view mode else { if ($oOrmItemSet instanceof \ormTagSet) { $aItems = $oOrmItemSet->GetTags(); $fExtractTagData = static function($oTag, &$sItemLabel, &$sItemDescription) { $sItemLabel = $oTag->Get('label'); $sItemDescription = $oTag->Get('description'); }; } else { $aItems = $oOrmItemSet->GetValues(); $oAttDef = MetaModel::GetAttributeDef($oOrmItemSet->GetClass(), $oOrmItemSet->GetAttCode()); $fExtractTagData = static function($sEnumSetValue, &$sItemLabel, &$sItemDescription) use ($oAttDef) { $sItemLabel = $oAttDef->GetValueLabel($sEnumSetValue); $sItemDescription = ''; }; } $oOutput->AddHtml('
') ->AddHtml(''); foreach($aItems as $sItemCode => $value) { $fExtractTagData($value, $sItemLabel, $sItemDescription); $sDescriptionAttr = (empty($sItemDescription)) ? '' : ' data-description="'.utils::HtmlEntities($sItemDescription).'"'; $oOutput->AddHtml('AddHtml($sDescriptionAttr) ->AddHtml('>') ->AddHtml($sItemLabel, true) ->AddHtml(''); } $oOutput->AddHtml('') ->AddHtml('
'); } $oOutput->AddHtml('
'); } return $oOutput; } }