Problem/Motivation

The value input of the math tamper plugin only accepts integers.

Decimal value input error
Scientific value input error

And it's weird because I already have an active math tamper multiplying by 1.0E-18 on the same site and I cannot think of a configuration change that could have broken the input in the meantime.

Steps to reproduce

Drupal 9.3.0
Feeds 8.x-3.0-beta1
Feeds Tamper 8.x-2.0-beta2
Add a feed type with a mapping to a Number (float) field
Add a math pluging tamper to that field

CommentFileSizeAuthor
#2 integer-error.png709.2 KBkopeboy
decimal.png20.89 KBkopeboy
scientific.png26.53 KBkopeboy

Comments

kopeboy created an issue. See original summary.

kopeboy’s picture

Issue summary: View changes
StatusFileSize
new709.2 KB

And when you actually put an integer, this error appears on saving
(but the plugin works as expected during feed import)

Feeds tamper Math plugin Integer Error

megachriz’s picture

I see that the number field in Drupal outputs HTML like this:

<input data-drupal-selector="edit-plugin-configuration-value" aria-describedby="edit-plugin-configuration-value--QgTWqzdOfUo--description" type="number" id="edit-plugin-configuration-value--QgTWqzdOfUo" name="plugin_configuration[value]" value="" step="1" class="form-number required" required="required" aria-required="true">

Note that the value of the step attribute is set to 1. I think this implies that only integers are accepted. According to
https://isotoma.com/blog/2012/03/02/html5-input-typenumber-and-decimalsf... that attribute should be set to "any" to allow decimal and float values too.

The code for the Math plugin is in tamper/src/Plugin/Tamper/Math.php. I think that the trick would be to instruct Drupal to use "any" as the value for the "step" attribute.

The error message seems to occur only when selecting the "division" operation.

kopeboy’s picture

Thank you for the quick reply!

For other readers, I found more relevant info here as well:
https://www.drupal.org/project/drupal/issues/2230909

megachriz’s picture

Status: Active » Closed (duplicate)

I think that this issue was fixed in the Tamper module in #3418803: Plugin Math: just integer values are accepted. If not, feel free to reopen.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.