下拉列表中的选定选项未显示

时间:2016-07-19 07:13:56

标签: php

我的网站www.ingeklikt.com上有一个下拉列表无法正常工作。

它显示一个空白字段而不是第一个选项或文本“选择一个选项”。

单击空白字段时,将显示下拉选项:

但是,单击一个后,该字段将再次变为空白。它确实记住了所选的选项(它会将您重定向到右岸的付款界面)。

我在Wordpress网站上使用Mollie Payment插件。这是代码:

<?php
class Mollie_WC_Gateway_Ideal extends Mollie_WC_Gateway_Abstract
{
    /**
     *
     */
    public function __construct ()
    {
        $this->supports = array(
            'products',
            'refunds',
        );

        /* Has issuers dropdown */
        $this->has_fields = TRUE;

        parent::__construct();
    }

    /**
     * @return string
     */
    public function getMollieMethodId ()
    {
        return Mollie_API_Object_Method::IDEAL;
    }

    /**
     * @return string
     */
    public function getDefaultTitle ()
    {
        return __('iDEAL', 'mollie-payments-for-woocommerce');
    }

    /**
     * @return string
     */
    protected function getDefaultDescription ()
    {
        /* translators: Default iDEAL description, displayed above issuer drop down */
        return __('Select your bank', 'mollie-payments-for-woocommerce');
    }

    /**
     * Display fields below payment method in checkout
     */
    public function payment_fields()
    {
        // Display description above issuers
        parent::payment_fields();

        $test_mode = Mollie_WC_Plugin::getSettingsHelper()->isTestModeEnabled();

        $ideal_issuers = Mollie_WC_Plugin::getDataHelper()->getIssuers(
            $test_mode,
            $this->getMollieMethodId()
        );

        $selected_issuer = $this->getSelectedIssuer();

        $html  = '<select name="' . Mollie_WC_Plugin::PLUGIN_ID . '_issuer_' . $this->id . '">';
    $html .= '<option value=""></option>';
        foreach ($ideal_issuers as $issuer)
        {
            $html .= '<option value="' . esc_attr($issuer->id) . '"' . ($selected_issuer == $issuer->id ? ' selected=""' : '') . '>' . esc_html($issuer->name) . '</option>';
        }
        $html .= '</select>';

        echo wpautop(wptexturize($html));
    }

    /**
     * @param WC_Order                  $order
     * @param Mollie_API_Object_Payment $payment
     * @param bool                      $admin_instructions
     * @param bool                      $plain_text
     * @return string|null
     */
    protected function getInstructions (WC_Order $order, Mollie_API_Object_Payment $payment, $admin_instructions, $plain_text)
    {
        if ($payment->isPaid() && $payment->details)
        {
            return sprintf(
                /* translators: Placeholder 1: consumer name, placeholder 2: consumer IBAN, placeholder 3: consumer BIC */
                __('Payment completed by <strong>%s</strong> (IBAN: %s, BIC: %s)', 'mollie-payments-for-woocommerce'),
                $payment->details->consumerName,
                implode(' ', str_split($payment->details->consumerAccount, 4)),
                $payment->details->consumerBic
            );
        }

        return parent::getInstructions($order, $payment, $admin_instructions, $plain_text);
    }
}

我觉得'选择名'行中有错误,但我无法弄清楚是什么。任何帮助将不胜感激!

1 个答案:

答案 0 :(得分:0)

也许我误解了这个问题,但你确实得到一个空白字段而不是第一个选项,因为你在列表顶部添加了一个空白选项

var name: String  // no need for setter or getter
var age: Int     // no need for setter or getter