AntonLV 7 anni fa
parent
commit
4b70f40d00

+ 7 - 21
modules/boonex/market/classes/BxMarketFormEntry.php

@@ -282,22 +282,16 @@ class BxMarketFormEntry extends BxBaseModTextFormEntry
     	return $aResult;
     }
 
-    protected function genCustomInputSubentries($aInput)
+    protected function genCustomInputSubentries ($aInput)
     {
-        $this->addCssJsUi();
-
         $CNF = &$this->_oModule->_oConfig->CNF;
 
-        $sGetSubentriesUrl = BX_DOL_URL_ROOT . $this->_oModule->_oConfig->getBaseUri() . 'get_subentries';
-        $sPlaceholder = bx_html_attribute(_t('_bx_market_form_entry_input_subentries_placeholder'), BX_ESCAPE_STR_QUOTE);
-
-        $this->oTemplate->addJs(array(
-            'jquery.form.min.js',
-        ));
+        $aInput['ajax_get_suggestions'] = BX_DOL_URL_ROOT . $this->_oModule->_oConfig->getBaseUri() . 'get_subentries';
+        $aInput['placeholder'] = _t('_bx_market_form_entry_input_subentries_placeholder');
 
         $sVals = '';
-        if (!empty($aInput['value']) && is_array($aInput['value'])) {
-            foreach ($aInput['value'] as $iValue) {
+        if(!empty($aInput['value']) && is_array($aInput['value'])) {
+            foreach($aInput['value'] as $iValue) {
                 $iValue = (int)$iValue;
                 if(!$iValue)
                     continue;
@@ -310,17 +304,9 @@ class BxMarketFormEntry extends BxBaseModTextFormEntry
             }
             $sVals = trim($sVals, ',');
         }
+        $aInput['value'] = $sVals;
 
-        return $this->oTemplate->parseHtmlByName('form_field_custom_suggestions.html', array(
-            'id' => $aInput['name'] . time(),
-            'url_get_recipients' => $sGetSubentriesUrl,
-            'name' => $aInput['name'],
-			'b_img' => 1,
-			'only_once' => 0,
-			'on_select' => 'null',
-		    'placeholder' => $sPlaceholder,
-            'vals' => $sVals,
-        ));
+        return $this->genCustomInputUsernamesSuggestions($aInput);
     }
 }
 

+ 10 - 6
template/scripts/BxBaseFormView.php

@@ -1117,14 +1117,18 @@ BLAH;
         $this->addCssJsUi();
 
         $sVals = '';
-        if(!empty($aInput['value']) && is_array($aInput['value'])) {
-            foreach($aInput['value'] as $sVal) {
-                if(!$sVal || !($oProfile = BxDolProfile::getInstance($sVal)))
-                    continue;
+        if(!empty($aInput['value'])) {
+            if(is_array($aInput['value'])) {
+                foreach($aInput['value'] as $sVal) {
+                    if(!$sVal || !($oProfile = BxDolProfile::getInstance($sVal)))
+                        continue;
 
-               $sVals .= '<b class="val bx-def-color-bg-hl bx-def-round-corners">' . $oProfile->getUnit(0, array('template' => 'unit_wo_info')) . $oProfile->getDisplayName() . '<input type="hidden" name="' . $aInput['name'] . '[]" value="' . $sVal . '" /></b>';
+                   $sVals .= '<b class="val bx-def-color-bg-hl bx-def-round-corners">' . $oProfile->getUnit(0, array('template' => 'unit_wo_info')) . $oProfile->getDisplayName() . '<input type="hidden" name="' . $aInput['name'] . '[]" value="' . $sVal . '" /></b>';
+                }
+                $sVals = trim($sVals, ',');
             }
-            $sVals = trim($sVals, ',');
+            else if(is_string($aInput['value']))
+                $sVals = $aInput['value'];
         }
 
         $bDisabled = isset($aInput['attrs']['disabled']) && $aInput['attrs']['disabled'] == 'disabled';