Merge pull request #27023 from HikeMike/add/hidden-form-field
"Hidden" field type added to woocommerce_form_field() #26468
This commit is contained in:
commit
51afe3207a
|
@ -2811,6 +2811,10 @@ if ( ! function_exists( 'woocommerce_form_field' ) ) {
|
|||
case 'tel':
|
||||
$field .= '<input type="' . esc_attr( $args['type'] ) . '" class="input-text ' . esc_attr( implode( ' ', $args['input_class'] ) ) . '" name="' . esc_attr( $key ) . '" id="' . esc_attr( $args['id'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" value="' . esc_attr( $value ) . '" ' . implode( ' ', $custom_attributes ) . ' />';
|
||||
|
||||
break;
|
||||
case 'hidden':
|
||||
$field .= '<input type="' . esc_attr( $args['type'] ) . '" class="input-hidden ' . esc_attr( implode( ' ', $args['input_class'] ) ) . '" name="' . esc_attr( $key ) . '" id="' . esc_attr( $args['id'] ) . '" value="' . esc_attr( $value ) . '" ' . implode( ' ', $custom_attributes ) . ' />';
|
||||
|
||||
break;
|
||||
case 'select':
|
||||
$field = '';
|
||||
|
|
|
@ -178,4 +178,19 @@ class WC_Tests_Template_Functions extends WC_Unit_Test_Case {
|
|||
|
||||
$this->assertEquals( $expected_html, $actual_html );
|
||||
}
|
||||
|
||||
public function test_hidden_field() {
|
||||
$actual_html = woocommerce_form_field('test',
|
||||
array(
|
||||
'type' => 'hidden',
|
||||
'id' => 'test_field',
|
||||
'input_class' => array( 'test-field' ),
|
||||
'custom_attributes' => array( 'data-total' => '10' ),
|
||||
'return' => true
|
||||
), 'test value');
|
||||
$expected_html = '<p class="form-row " id="test_field_field" data-priority=""><span class="woocommerce-input-wrapper"><input type="hidden" class="input-hidden test-field" name="test" id="test_field" value="test value" data-total="10" /></span></p>';
|
||||
|
||||
$this->assertEquals( $expected_html, $actual_html );
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue