Table of Contents

#200 — Every saved item shows an Edit button that links to `/items?item_id=N`, which returns the same empty "Add an item" form — no ite (Resolved)

← Back to bug list · View issue #200 in MantisBT


Reported by: Nour aboulhosn on 2026-08-08T12:20:37+01:00
Assigned to: Claude
Resolved by: Claude on 2026-08-08T14:07:36+01:00
Severity: major
Priority: high
Reproducibility: have not tried
Category: General

Description: Each row in Saved items carries an Edit control pointing at `/items?item_id=4`. That URL returns a page identical to `/items`: the same heading “Add an item”, the same form posting to `POST /items`, and `name`, `unit_price` and `unit` all still `value=““`. The `item_id` is not carried into the form as a hidden field, and the only other item route is `POST /items/{id}/delete`.

So there is no way to correct an item's price, unit or name once saved. The button looks like it works — the URL changes and the page reloads — which is worse than having no button at all.

Anyone who tries anyway is really filling in the create form, so the item they meant to correct is left untouched. Loading the item into the form and posting to an update route would fix it.

Steps to Reproduce: 1. Go to Saved items, where several items are listed with their price and unit. 2. Click Edit on any of them, for example `QA NonTaxable` at `$100.00 / ea`. The URL becomes `/items?item_id=4`. 3. The form below still reads “Add an item” and every field is empty — the item's name, price and unit are not loaded. 4. Compare the page source with plain `/items`: the form action is `POST /items` in both, and neither carries an `item_id`. 5. Fill the form in to “save the edit” and the item is not updated — the request is a create, so the item you meant to change is still there, unchanged.

Resolution: What — the Edit control on every saved item pointed at `/items?item_id=N`, which returned the same empty “Add an item” form. Anyone who used it was really filling in the create form, so the item they meant to correct was left untouched and a second one appeared beside it.

Where — `ItemController::index()`.

Why — `store()` has handled an incoming `item_id` as an update the whole time. Only the LOADING half was missing: `index()` never read the query parameter, so `$input` stayed empty and the form rendered blank and posted to the create path. The URL changed and the page reloaded, which is what made the button look like it worked.

Fix — `index()` loads the named item into `$input` when there is no flashed input to show. The flashed input WINS over the stored row, and that ordering is the point: after a refused save the reader must get their own typing back, not have it replaced by what is still in the database. The price is re-rendered at `RATE_SCALE`, not money scale, so opening a $0.0015 item to change its unit does not quietly retype it as $0.00.

Verified on the running app: `/items?item_id=1` returns the form headed Edit with `item_id=1`, `name=QA Unique 8081`, `unit_price=10`, `unit=box`; posting it back with a new price and unit updates that row (14.5000 / case) and leaves the item count at one.

Activity / Notes

Where — `ItemController::index()`.

Why — `store()` has handled an incoming `item_id` as an update the whole time. Only the LOADING half was missing: `index()` never read the query parameter, so `$input` stayed empty and the form rendered blank and posted to the create path. The URL changed and the page reloaded, which is what made the button look like it worked.

Fix — `index()` loads the named item into `$input` when there is no flashed input to show. The flashed input WINS over the stored row, and that ordering is the point: after a refused save the reader must get their own typing back, not have it replaced by what is still in the database. The price is re-rendered at `RATE_SCALE`, not money scale, so opening a $0.0015 item to change its unit does not quietly retype it as $0.00.

Verified on the running app: `/items?item_id=1` returns the form headed Edit with `item_id=1`, `name=QA Unique 8081`, `unit_price=10`, `unit=box`; posting it back with a new price and unit updates that row (14.5000 / case) and leaves the item count at one.

Full History

Date User Field Change
2026-08-08T12:20:37+01:00 Nour aboulhosn issue-new New Issue
2026-08-08T14:07:35+01:00 Claude note-added Note Added: 0000158
2026-08-08T14:07:36+01:00 Claude tag-added Tag Attached: done-by-claude
2026-08-08T14:07:36+01:00 Claude Assigned To ⇒ Claudine
2026-08-08T14:07:36+01:00 Claude Status new ⇒ resolved

Synced automatically from MantisBT issue #200.