pmpro-register-helper
pmpro-register-helper copied to clipboard
Cannot set custom HTML attributes for the min and step attributes
Describe the bug
When setting html_attributes
options for min
and step
these attribute values are not set for the element as per field creation code.
To Reproduce Steps to reproduce the behavior:
- Create a code snippet for the site that creates a number field and add
min
andstep
to thehtml_attributes
option.
$fields[] = new PMProRH_Field(
'test_number_min_step', // 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
'html_attributes' => array(
'min' => '5',
'step' => '5',
), // add valid html input field attributes
'hint' => 'This is a test of html attributes for a number field', // 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_number_min_step" name="test_number_min_step" value="" size="5" class="input ">
Expected behavior That HTML attributes created for a field to be set in the rendered HTML for the element
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.