pmpro-register-helper
pmpro-register-helper copied to clipboard
Cannot set 0 (zero) as the default value for a number field
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:
- Create a code snippet for the site that creates a number field and set the
value
option for the field to0
$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
)
);
- Navigate to the Membership Checkout page on the frontend.
- Inspect rendered HTML for the number field.
- 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
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.