1

我需要在我的 select.genericlist 中添加一个 select.optgroup,这是我的代码:

foreach ($this->methods as $method) {
      if ($this->checkConditions($cart, $method, $cart->pricesUnformatted)) {
          $methodSalesPrice = $this->calculateSalesPrice($cart, $method, $cart->pricesUnformatted);
          $method->$method_name = $this->renderPluginName($method);

              $session = JFactory::getSession();
              $htmlI[] = $this->getPluginHtml($method, $selected, $methodSalesPrice);
              // this is my attempt
              $htmlI[] = JHTML::_('Select.optgroup', 'My optgroup');
              // my attempt ends here
              $htmlI[] = JHTML::_('Select.genericlist', $this->banks, 'service_issuer', 'size=1', 'key', 'value', $session->get('service_issuer', 0, 'vm'));
              $html[] = $htmlI;


      }
  }

这将返回以下内容:

array

有没有人这样做过?非常感谢您的建议

4

1 回答 1

1

我已经设法自己修复它,下面是工作代码

if($method->payment_method == "mymethod") {
              $session = JFactory::getSession();
              $htmlI = $this->getPluginHtml($method, $selected, $methodSalesPrice);
              $banksEra[] = JHTML::_('select.option', '', JText::_('VMPAYMENT_BANKS'));
              $banksEra[] = JHTML::_('select.optgroup', 'Countries');
              foreach ($this->banksEra as $key => $value) {
                $banksEra[] = JHTML::_( 'select.option', $key, $value );
              }
              $htmlI .= JHTML::_('select.genericlist', $banksEra, 'issuer', 'class="inputbox"', 'value', 'text', $session->get('issuer', 0, 'vm'));
              $html[] = $htmlI;
          }
于 2013-03-04T11:56:02.920 回答