pmpro-register-helper icon indicating copy to clipboard operation
pmpro-register-helper copied to clipboard

Cannot set 0 (zero) as the default value for a number field

Open ipokkel opened this issue 3 years ago • 0 comments

Describe the bug When setting the value option to 0 (zero) for a number field so the default number displayed for the field is 0 the field instead displays no value.

To Reproduce Steps to reproduce the behavior:

  1. Create a code snippet for the site that creates a number field and set the value option for the field to 0
$fields[] = new PMProRH_Field(
		'test_value_zero', // input field name, used as meta key
		'number',         // field type
		array(
			'label'           => 'Number Test', // display custom label, if not used field name will be used
			'value'           => '0',
			'hint'            => 'Testing 0 (zero) as the default value', // display a hint under field
			'profile'         => true, // show on profile
		)
	);
  1. Navigate to the Membership Checkout page on the frontend.
  2. Inspect rendered HTML for the number field.
  3. See error
<input type="number" min="0" step="1" pattern="\d+" id="test_value_zero" name="test_value_zero" value="" size="5" class="input ">

Screenshots 211215-1639557253

Expected behavior If a value of 0 is set for the number field that the field displays 0 as its starting value.

Isolating the problem (mark completed items with an [x]):

  • [x] I have deactivated other plugins and confirmed this bug occurs when only Paid Memberships Pro plugin is active.
  • [x] This bug happens with a default WordPress theme active, or Memberlite.
  • [x] I can reproduce this bug consistently using the steps above.

ipokkel avatar Dec 15 '21 08:12 ipokkel