Skip to content

Backpex.Fields.Currency behaving incorrectly #1698

@thanos

Description

@thanos

Describe the bug
Backpex.Fields.Currency.render_form/1 shows a blank value. Also when a new value is entered that record is not being updated with the new value.

To Reproduce
Steps to reproduce the behavior:

  1. checkout develop
  2. Go to /admin/products/ chose a record
Image

This example shows a price of $3,291.41

  1. Go to edit it and the field shows price blank:
Image
  1. change another field save and the value is retrieved
Image
  1. Go back to end and now update the blank price field with a value for example 9999.99 (I'll also update quantity to force an update otherwise there is no change registered by changeset), the original value is not updated.

Both validate and save show the original value, and update only changes quantity.

[debug] HANDLE EVENT "validate" in DemoWeb.ProductLive.Form
  Component: Backpex.FormComponent
  Parameters: %{"_target" => ["undefined"], "change" => %{"_unused_manufacturer" => "", "_unused_name" => "", "_unused_short_links_delete" => [""], "_unused_short_links_order" => [""], "images_used_input" => "false", "manufacturer" => "https://example.com/", "name" => "Agar", "price" => "$3,291.41", "quantity" => "844", "short_links" => %{"0" => %{"_persistent_id" => "0", "_unused_short_key" => "", "_unused_url" => "", "short_key" => "NOMEYAdv", "url" => "https://example.com/"}}, "short_links_delete" => [""], "short_links_order" => ["0"], "suppliers_delete" => [""]}}

[debug] Replied in 3ms

[debug] HANDLE EVENT "save" in DemoWeb.ProductLive.Form
  Component: Backpex.FormComponent
  Parameters: %{"change" => %{"images_used_input" => "false", "manufacturer" => "https://example.com/", "name" => "Agar", "price" => "$3,291.41", "quantity" => "844", "short_links" => %{"0" => %{"_persistent_id" => "0", "short_key" => "NOMEYAdv", "url" => "https://example.com/"}}, "short_links_delete" => [""], "short_links_order" => ["0"], "suppliers_delete" => [""]}, "save-type" => "save"}

[debug] QUERY OK source="products" db=1.8ms queue=1.6ms idle=1749.0ms
UPDATE "products" SET "quantity" = $1, "updated_at" = $2 WHERE "id" = $3 [844, ~N[2025-12-08 02:46:07], "717a6139-e0a4-4868-9a8b-0cdbfcbe53f6"]

Please complete the following information:

  • OS: OSX ventura
  • Browser : Chrome Version 142.0.7444.176 (Official Build) (arm64)
  • Elixir Version: 1.18.4-otp-28
  • Backpex Version: 0.16.3

The issue is also for Currency fields in inline_crud. Saw it when testing pull request #1607 so tried out head and hence this ticket.
Its 22:00 EST here, but I guess can work on it tomorrow when I get home

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions