Fix: Categories Edit form model binding with explicit attributes
**Issue**: Edit category form not displaying existing values and not updating - Form fields were empty when loading edit page - Submitting changes had no effect on the category **Root Cause**: - Edit view used asp-for helpers which don't bind properly in production - Create view used explicit name/id attributes which work reliably - Model values weren't being rendered in the form fields **Solution**: - Changed from asp-for helpers to explicit name/id attributes - Added value="@Model.Name" to populate name input - Added @Model.Description between textarea tags - Changed checkbox to @(Model.IsActive ? "checked" : "") - Matches the working pattern from Create.cshtml **Files Changed**: - LittleShop/Areas/Admin/Views/Categories/Edit.cshtml - Line 29: Input with value="@Model.Name" - Line 35: Textarea with @Model.Description content - Line 41: Checkbox with @(Model.IsActive ? "checked" : "") **Testing**: - Deployed to production (container: f86abfb2334b, healthy) - Form now displays existing category values - Updates save correctly to database 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
8a3341b59f
commit
125513dbc6
@ -25,21 +25,21 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label asp-for="Name" class="form-label">Name</label>
|
<label for="Name" class="form-label">Name</label>
|
||||||
<input asp-for="Name" class="form-control" />
|
<input name="Name" id="Name" class="form-control" value="@Model.Name" required />
|
||||||
<span asp-validation-for="Name" class="text-danger"></span>
|
<span class="text-danger"></span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label asp-for="Description" class="form-label">Description</label>
|
<label for="Description" class="form-label">Description</label>
|
||||||
<textarea asp-for="Description" class="form-control" rows="3"></textarea>
|
<textarea name="Description" id="Description" class="form-control" rows="3">@Model.Description</textarea>
|
||||||
<span asp-validation-for="Description" class="text-danger"></span>
|
<span class="text-danger"></span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<div class="form-check">
|
<div class="form-check">
|
||||||
<input asp-for="IsActive" class="form-check-input" type="checkbox" />
|
<input name="IsActive" id="IsActive" class="form-check-input" type="checkbox" @(Model.IsActive ? "checked" : "") />
|
||||||
<label asp-for="IsActive" class="form-check-label">
|
<label for="IsActive" class="form-check-label">
|
||||||
Active
|
Active
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user