Wordpress 使中继器测试版';第一个条目所需的s字段
因此,我正在使用针对Gravity Forms()的Repeater beta插件,我需要将其设置为必需的,或者更具体地说,是字段中的第一个条目。我尝试过各种各样的方法,但都无济于事,也不知道为什么Wordpress 使中继器测试版';第一个条目所需的s字段,wordpress,gravity-forms-plugin,Wordpress,Gravity Forms Plugin,因此,我正在使用针对Gravity Forms()的Repeater beta插件,我需要将其设置为必需的,或者更具体地说,是字段中的第一个条目。我尝试过各种各样的方法,但都无济于事,也不知道为什么 我尝试将中继器内的字段“required”设置为true 我尝试将中继器字段本身的“required”设置为true 我试着让中继器字段和其中的字段符合要求 在admin中,每次我单击repeater字段的“Required”复选框时,该复选框在保存表单后都会被取消选中 使用$(窗口).load我
- 我尝试将中继器内的字段“required”设置为true
- 我尝试将中继器字段本身的“required”设置为true
- 我试着让中继器字段和其中的字段符合要求
- 在admin中,每次我单击repeater字段的“Required”复选框时,该复选框在保存表单后都会被取消选中
- 使用
我尝试向中继器中的所有字段添加$(窗口).load
属性,但这会阻止表单中的唯一字段向用户显示任何“required”消息,并且实际上只检查中继器中的第一个空字段。其余部分,即使为空,也不会显示“必需”消息required=required
- 使用
,但结果与上面类似,但其余表单字段再次开始验证$(document).ready()
- 浏览Gravity Forms论坛,但找不到我想要的答案,我不知道任何人回答我的问题需要多长时间,这不能等几天或几周
functions.php
中为中继器设置的所有代码,根据字段的文档示例:
// Adjust your form ID
add_filter( 'gform_form_post_get_meta_5', 'add_my_field' );
function add_my_field( $form ) {
// Create a Single Line text field for the product member's name
$purchasedFrom = GF_Fields::create( array(
'type' => 'text',
'id' => 1002, // The Field ID must be unique on the form
'formId' => $form['id'],
'required' => true,
'label' => 'Purchased From',
'pageNumber' => 1, // Ensure this is correct
) );
$itemtype = GF_Fields::create( array(
'type' => 'text',
'id' => 1007, // The Field ID must be unique on the form
'formId' => $form['id'],
'required' => true,
'label' => 'Item Type',
'pageNumber' => 1, // Ensure this is correct
) );
// Create an email field for the product s
$quantity = GF_Fields::create( array(
'type' => 'text',
'id' => 1001, // The Field ID must be unique on the form
'formId' => $form['id'],
'required' => true,
'label' => 'Quantity',
'pageNumber' => 1, // Ensure this is correct
) );
$purchasedDate = GF_Fields::create( array(
'type' => 'text',
'id' => 1003, // The Field ID must be unique on the form
'formId' => $form['id'],
'label' => 'Date of Purchase',
'required' => true,
'pageNumber' => 1, // Ensure this is correct
) );
$serviceDate = GF_Fields::create( array(
'type' => 'text',
'id' => 1004, // The Field ID must be unique on the form
'required' => true,
'formId' => $form['id'],
'label' => 'Date Out of Service',
'pageNumber' => 1, // Ensure this is correct
) );
$size = GF_Fields::create( array(
'type' => 'text',
'required' => true,
'id' => 1009, // The Field ID must be unique on the form
'formId' => $form['id'],
'label' =>'Size',
'pageNumber' => 1, // Ensure this is correct
) );
$upc = GF_Fields::create( array(
'type' => 'text',
'required' => true,
'id' => 1010, // The Field ID must be unique on the form
'formId' => $form['id'],
'label' => 'UPC/Part # (From Receipt)',
'pageNumber' => 1, // Ensure this is correct
) );
$damage = GF_Fields::create( array(
'type' => 'text',
'required' => true,
'id' => 1005, // The Field ID must be unique on the form
'formId' => $form['id'],
'label' => 'Description of Damage',
'pageNumber' => 1, // Ensure this is correct
) );
// Create a repeater for the product and add the name and email fields as the fields to display inside the repeater.
$product = GF_Fields::create( array(
'type' => 'repeater',
'required' => true,
'id' => 1000, // The Field ID must be unique on the form
'formId' => $form['id'],
'label' => 'Add Products',
'addButtonText' => 'Add Another Product',
'removeButtonText'=> 'Remove Product',
'pageNumber' => 1, // Ensure this is correct
'fields' => array( $purchasedFrom,$itemtype, $quantity, $purchasedDate,$serviceDate, $size, $upc, $damage), // Add the fields here.
) );
$form['fields'][] = $product;
return $form;
}
// Remove the field before the form is saved. Adjust your form ID
add_filter( 'gform_form_update_meta_5', 'remove_my_field', 10, 3 );
function remove_my_field( $form_meta, $form_id, $meta_name ) {
if ( $meta_name == 'display_meta' ) {
// Remove the Repeater field: ID 1000
$form_meta['fields'] = wp_list_filter( $form_meta['fields'], array( 'id' => 1000 ), 'NOT' );
}
return $form_meta;
}
我确实需要以某种方式要求该字段,特别是第一个条目,以便用户知道输入至少一个产品。我遗漏了什么?您好,您只需将它们标记为: “isRequired”=>正确 而不是 “必需”=>true 更改后,请确保从表单中删除repeater并进行更新。中继器应再次出现,单击更新并检查结果