添加产品时,如何在woocommerce产品页面中设置必填(必填)自定义字段值 [英] How can i make custom field value required ( compulsory ) in woocommerce product page when adding product
本文介绍了添加产品时,如何在woocommerce产品页面中设置必填(必填)自定义字段值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在woocommerce的添加产品"页面中添加了自定义文本框字段.现在我要使其成为必需的(强制性的).我通过传递参数"required" => true进行了尝试.但它不起作用.请参见下面的代码
I have added custom text box field in my add product page in woocommerce. Now i want to make it required (compulsory). I tried it by passing argument "required"=>true. but it is not working. Please see below code
woocommerce_wp_text_input(
array(
'id' => 'special_price',
'label' => __( 'Wholesaler Price *', 'woocommerce' ),
'placeholder' => '',
'desc_tip' => 'true',
'required' => 'true',
'description' => __( 'Enter wholesaler price here.', 'woocommerce' )
)
);
但是它不是强制性的文本框.请任何人告诉我该怎么做?
but it is not making textbox compulsory. Please can anyone tell how can i do this?
推荐答案
对于必需的
HTML5属性和其他自定义属性 woocommerce_wp_text_input()
函数具有 custom_attributes
选项.
For the required
HTML5 attribute and other custom attributes woocommerce_wp_text_input()
function has custom_attributes
option.
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' )
)
);
这篇关于添加产品时,如何在woocommerce产品页面中设置必填(必填)自定义字段值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文