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
Leading zero values not respected #869
Comments
Is there a particular field configuration that causes this for you? |
This is the field definition:
|
I am having a related issue with the code that @gyrus referred to: https://github.com/CMB2/CMB2/blob/trunk/includes/types/CMB2_Type_Multi_Base.php#L81-L83. My issue is that I'm dynamically populating the select options with Gravity Forms field IDs, so sometimes the value is a float, such as |
@timothyjensen since you have the optimal testing scenario, can you test by changing those lines to this: if ( is_numeric( $value ) ) {
$value = is_float( $value ) ? floatval( $value ) : intval( $value );
} |
@jtsternberg Thanks for addressing this. Unfortunately the code you suggested doesn't quite fix the issue. I should have been more accurate in my previous description; the option value is saved as a string in the database. Because of that |
Can you please test #1013? |
Works perfectly! |
I added some leading zero unit tests as well: c2c4d47 Thanks for testing, i'll merge it in now. |
…e problems. See #869. Squashed commit of the following: commit c2c4d47 Author: Justin Sternberg <justin@dsgnwrks.pro> Date: Wed Aug 16 09:31:15 2017 -0400 Test leading zero values as well. For #869 commit 45ade84 Author: Justin Sternberg <justin@dsgnwrks.pro> Date: Tue Aug 15 18:43:54 2017 -0400 Add CMB2_Utils::normalize_if_numeric to address floats as select value problems. See #869 commit 94cf8bb Author: Justin Sternberg <justin@dsgnwrks.pro> Date: Tue Aug 15 17:45:36 2017 -0400 Fix "PHP Strict Standards: Static function should not be abstract"
If a select is populated with, say, months, where leading zeros are added to numeric values (e.g. December is
12
but January is01
) the correct value should be selected after saving.However, this isn't the case. I think it's these lines in 2.2.4,
includes/types/CMB2_Type_Multi_Base.php:77
:Is there a reason for this?
The text was updated successfully, but these errors were encountered: