Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Set number field value if value is 0 (zero) #228

Closed
wants to merge 1 commit into from

Conversation

ipokkel
Copy link
Member

@ipokkel ipokkel commented Dec 15, 2021

Accept 0 (zero) as a value set for a number field's value option.

All Submissions:

Changes proposed in this Pull Request:

Added additional logic to check if a value was set and is numeric to allow a default value of 0

Resolves #226

How to test the changes in this Pull Request:

  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 to confirm the value is set as 0

Other information:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you successfully run tests with your changes locally?

Changelog entry

BUGFIX/ENHANCEMENT: Accept 0 (zero) as the default value displayed for a number field.

Set the default number now when the field settings for value is a 0
@ideadude
Copy link
Member

Thanks, Theuns! Took a slightly different route and updated PMPro core to support values like 0 and '0' here: strangerstudios/paid-memberships-pro@7a1838c

@ideadude ideadude closed this Jul 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

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