我在woocommerce的添加产品页面中添加了自定义文本框字段。现在我要使其成为必需的(强制性的)。我通过传递参数“ required” => true进行了尝试。但它不起作用。请看下面的代码
woocommerce_wp_text_input(
array(
'id' => 'special_price',
'label' => __( 'Wholesaler Price *', 'woocommerce' ),
'placeholder' => '',
'desc_tip' => 'true',
'required' => 'true',
'description' => __( 'Enter wholesaler price here.', 'woocommerce' )
)
);
但这并不是强制性的文本框。请谁能告诉我该怎么做?
对于required
HTML5属性和其他自定义属性,woocommerce_wp_text_input()
函数具有custom_attributes
选项。
woocommerce_wp_text_input(
array(
'id' => 'special_price',
'label' => __( 'Wholesaler Price *', 'woocommerce' ),
'placeholder' => '',
'desc_tip' => 'true',
'custom_attributes' => array( 'required' => 'required' ),
'description' => __( 'Enter wholesaler price here.', 'woocommerce' )
)
);
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句