CalderaWP / Caldera-Forms

Drag and drop, responsive WordPress form builder.
https://CalderaForms.com
GNU General Public License v2.0
187 stars 163 forks source link

Unless steps setting is used, number fields with decimals not considered valid #2402

Open Shelob9 opened 6 years ago

Shelob9 commented 6 years ago

Maybe related: https://github.com/guillaumepotier/Parsley.js/issues/1129

Presumably broken via: #2346

If a number field has a decimal it does not validate properly on form submission, multi-page validation works.

Shelob9 commented 6 years ago

Immediate work around is to set 0.1 as the value for the "steps" setting for your number field.

Or use the caldera_forms_field_attributes-number filter.

See: https://calderaforms.com/doc/caldera_forms_field_attributes/

add_filter( 'caldera_forms_field_attributes-number', function( $attrs ){
    $attrs[ 'step' ] = 'any';
    return $attrs;
});
Shelob9 commented 6 years ago

So here is the thing, if you do not have the step attribute set, 1.5 is not valid according to HTML5 as implemented in Chrome. I made a whole CodePen to remind myself how exactly HTML5 works: https://codepen.io/Shelob9/pen/qoyXrK?editors=1000

So basically, Caldera Forms 1.6.0 restores the correct functionality for number fields as it relates to the step attribute.

But in Caldera Forms 1.5.9.1 if you have a number input without setting the step attribute, and enter 1.555, that's valid, because of a bug in the validation library we're using - Parsely.

So to clarify:

Options:

  1. We can close this without fixing. The forms will work according to HTML5 spect. Say the old behaviour was a bug, and it's now fixed.
  2. We can re-introduce the bug, and forms will not work according to the HTML5 spec.
  3. We can output "any" as the value for step attribute if no value for step is saved.
  4. We can make this more clear in the UI
Shelob9 commented 6 years ago

I'm punting this as I'm not sure if it should be fixed or not.

brustar64 commented 6 years ago

To clarify - is .1 the best step value if we are working with "money"? I tried this and I still got "this value seems to be invalid

brustar64 commented 6 years ago

I tried 0.05 and that fixed it :)

Shelob9 commented 6 years ago

That setting controls the value of the "step" attribute of the input.

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/number#step

I would consider this a bug if the behavior of our number field was not to the spec.

If you set .1, then 1.01 is not valid. If you set steps to .01, then 1.01 will be valid.

On Wed, Nov 7, 2018, 7:09 AM brustar64 <notifications@github.com wrote:

I tried 0.05 and that fixed it :)

— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub https://github.com/CalderaWP/Caldera-Forms/issues/2402#issuecomment-436602864, or mute the thread https://github.com/notifications/unsubscribe-auth/AB5uR-1seqG6Cw9Q9c0ygY3Fu1Dv_vnoks5uss1dgaJpZM4TFn2Y .

brustar64 commented 5 years ago

Thanks Josh,

I'm not sure why that didn't work the first time I tried it. I used 0.01 this time instead of just .01 and that works so maybe that was the issue.

regards Bruce


From: Josh Pollock notifications@github.com Sent: Thursday, 8 November 2018 4:44 AM To: CalderaWP/Caldera-Forms Cc: brustar64; Comment Subject: Re: [CalderaWP/Caldera-Forms] Unless steps setting is used, number fields with decimals not considered valid (#2402)

That setting controls the value of the "step" attribute of the input.

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/number#step

I would consider this a bug if the behavior of our number field was not to the spec.

If you set .1, then 1.01 is not valid. If you set steps to .01, then 1.01 will be valid.

On Wed, Nov 7, 2018, 7:09 AM brustar64 <notifications@github.com wrote:

I tried 0.05 and that fixed it :)

— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub https://github.com/CalderaWP/Caldera-Forms/issues/2402#issuecomment-436602864, or mute the thread https://github.com/notifications/unsubscribe-auth/AB5uR-1seqG6Cw9Q9c0ygY3Fu1Dv_vnoks5uss1dgaJpZM4TFn2Y .

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/CalderaWP/Caldera-Forms/issues/2402#issuecomment-436733631, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AbqjrzFj3p4UIXY5ltQzluZ314dZhNTKks5usyoWgaJpZM4TFn2Y.