【发布时间】:2017-08-10 11:50:20
【问题描述】:
我检查了一些其他主题,但没有一个适合我在页面加载时将复选框设置为选中的情景。
复选框与数据库无关,它只是让代码查看它是否被选中。我知道如何在 HTML 和 PHP 中执行此操作,但我有一个 Wordpress 插件,它有一个复选框,我需要在页面加载时选中它。
以下是显示复选框的代码,但我不知道要添加什么以使其在页面加载时将复选框设置为选中:
$is_offers_enabled = get_post_meta($object_id, 'offers_for_woocommerce_enabled', true);
$is_offers_enabled = ($is_offers_enabled == 'yes') ? 'yes' : 'no';
WCVendors_Pro_Form_Helper::input( apply_filters( 'ofwcv_offers_for_woocommerce_enabled', array(
'id' => 'offers_for_woocommerce_enabled',
'label' => __( 'Enable Offers?', 'offers-for-woocommerce-wc-vendors' ),
'type' => 'checkbox',
'value' => $is_offers_enabled,
'class' => 'ofwcv_offers_for_woocommerce_enabled',
'wrapper_start' => '<div class="wcv-cols-group wcv-horizontal-gutters"><div class="all-50 small-100">',
'wrapper_end' => '</div>'
) )
);
【问题讨论】:
-
你不能把 'checked' => 'checked' 添加到那个数组吗?