AntonLV 6 лет назад
Родитель
Сommit
593fa42282
3 измененных файлов с 43 добавлено и 51 удалено
  1. 5 11
      inc/classes/BxDolLabel.php
  2. 38 3
      template/scripts/BxBaseFormView.php
  3. 0 37
      template/scripts/BxBaseLabelForm.php

+ 5 - 11
inc/classes/BxDolLabel.php

@@ -62,17 +62,6 @@ class BxDolLabel extends BxDolFactory implements iBxDolSingleton
         echoJson($aResult);
     }
 
-    public function getFormElement($aInput = array())
-    {
-        $oForm = BxDolForm::getObjectInstance($this->_sForm, $this->_sFormDisplaySelect);
-        if(!$oForm)
-            return '';
-
-        $aInput['attrs']['id'] = $this->_aHtmlIds['labels_element'] . $aInput['name'];
-
-        return $oForm->getFormElement($aInput);
-    }
-
     public function getLabels($aParams = array())
     {
         return $this->_oDb->getLabels($aParams);
@@ -99,6 +88,11 @@ class BxDolLabel extends BxDolFactory implements iBxDolSingleton
         return $sUrl;
     }
 
+    public function getFormFieldId($aInput = array())
+    {
+        return !empty($aInput['name']) ? $this->_aHtmlIds['labels_element'] . $aInput['name'] : 'bx-form-element-labels';
+    }
+
     public function onAdd($iId)
     {
         $aLabel = $this->_oDb->getLabels(array('type' => 'id', 'id' => $iId));

+ 38 - 3
template/scripts/BxBaseFormView.php

@@ -1460,10 +1460,45 @@ BLAH;
 
     protected function genCustomInputLabels ($aInput)
     {
-        if(!empty($aInput['value']) && !is_array($aInput['value']))
-            $aInput['value'] = unserialize($aInput['value']);
+        $oLabel = BxDolLabel::getInstance();
+
+        $sName = !empty($aInput['name']) ? $aInput['name'] : 'labels';
+
+        $sValue = '';
+        if(!empty($aInput['value'])) {
+            if(!is_array($aInput['value']))
+                $aInput['value'] = unserialize($aInput['value']);
+
+            if(is_array($aInput['value']))
+                foreach($aInput['value'] as $sLabel)
+                    $sValue .= $oLabel->getLabel($sName, $sLabel);
+        }
 
-        return BxDolLabel::getInstance()->getFormElement($aInput);
+        $sKeyPlaceholder = $aInput['caption_src'] . '_placeholder';
+        if(strcmp($sKeyPlaceholder, _t($sKeyPlaceholder)) != 0)
+            $sValue .= $oLabel->getLabelPlaceholder($sKeyPlaceholder);           
+
+        $aInputLabels = array(
+            'type' => 'custom',
+            'name' => $sName,
+            'caption' => '',
+            'value' => $sValue,
+            'ajax_get_suggestions' => BX_DOL_URL_ROOT . bx_append_url_params('label.php', array(
+                'action' => 'labels_list',
+            )),
+            'attrs' => array(
+                'class' => 'bx-form-input-labels',
+                'disabled' => 'disabled'
+            )
+        );
+
+        return $this->oTemplate->parseHtmlByName('label_select_field.html', array(
+            'js_object' => $oLabel->getJsObjectName(),
+            'js_code' => $oLabel->getJsCodeForm(),
+            'html_id' => $oLabel->getFormFieldId($aInput),
+            'name' => $sName,
+            'input_labels' => $this->genCustomInputUsernamesSuggestions($aInputLabels)
+        ));
     }
     
     /**

+ 0 - 37
template/scripts/BxBaseLabelForm.php

@@ -29,43 +29,6 @@ class BxBaseLabelForm extends BxTemplFormView
         return parent::initChecker($aValues, $aSpecificValues);
     }
 
-    public function getFormElement($aInput = array())
-    {
-        $sName = !empty($aInput['name']) ? $aInput['name'] : 'labels';
-        $sHtmlId = !empty($aInput['attrs']['id']) ? $aInput['attrs']['id'] : 'bx-form-element-labels';
-
-        $sValue = '';
-        if(!empty($aInput['value']) && is_array($aInput['value']))
-            foreach($aInput['value'] as $sLabel)
-                $sValue .= $this->_oObject->getLabel($sName, $sLabel);
-
-        $sKeyPlaceholder = $aInput['caption_src'] . '_placeholder';
-        if(strcmp($sKeyPlaceholder, _t($sKeyPlaceholder)) != 0)
-            $sValue .= $this->_oObject->getLabelPlaceholder($sKeyPlaceholder);           
-
-        $aInputLabels = array(
-            'type' => 'custom',
-            'name' => $sName,
-            'caption' => '',
-            'value' => $sValue,
-            'ajax_get_suggestions' => BX_DOL_URL_ROOT . bx_append_url_params('label.php', array(
-                'action' => 'labels_list',
-            )),
-            'attrs' => array(
-                'class' => 'bx-form-input-labels',
-                'disabled' => 'disabled'
-            )
-        );
-
-        return $this->oTemplate->parseHtmlByName('label_select_field.html', array(
-            'js_object' => $this->_oObject->getJsObjectName(),
-            'js_code' => $this->_oObject->getJsCodeForm(),
-            'html_id' => $sHtmlId,
-            'name' => $sName,
-            'input_labels' => $this->genCustomInputUsernamesSuggestions($aInputLabels)
-        ));
-    }
-
     protected function genCustomInputSearch($aInput)
     {
         $aInput = array_merge($aInput, array(