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

Number field type, with decimals, fails if string is entered #3059

Closed
nicolasbinet opened this issue Jul 3, 2018 · 4 comments
Closed

Number field type, with decimals, fails if string is entered #3059

nicolasbinet opened this issue Jul 3, 2018 · 4 comments

Comments

@nicolasbinet
Copy link

nicolasbinet commented Jul 3, 2018

Description

When entering texts in a Number field type with decimals, validation fails, returning an error

PHP Warning – yii\base\ErrorException
number_format() expects parameter 1 to be float, string given

Here is a full error log https://gist.github.com/nicolasbinet/bc241f35003cb01335f0a38a2de69946

Steps to reproduce

  1. Create a new Number field
  2. Set decimals
  3. Add field to Section type
  4. Create a new entry
  5. Type some random text
  6. Validate

Additional info

  • Craft version: 3.0.13.2
  • PHP version: 7.0
@brandonkelly
Copy link
Member

Fixed just in time for the 3.0.14 release :)

@nicolasbinet
Copy link
Author

Why it the format Number not enforced trough input[type=text] in the form ?
Not for security reasons, but it would help guiding user through editing.

@brandonkelly
Copy link
Member

Because <input type="number"> requires en-US-style number formats (, as thousands separator, . as decimal), but other locales don’t always use those same characters. E.g. , is often used as the decimal character.

@nicolasbinet
Copy link
Author

@brandonkelly thanks.

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

No branches or pull requests

2 participants