Files
digital-garage-sale/app/templates/admin/edit_item.html
2025-04-29 13:54:11 -07:00

57 lines
2.7 KiB
HTML

{% extends "admin/base.html" %}
{% block title %}Edit Item - Digital Garage Sale{% endblock %}
{% block content %}
<h2>Edit Item</h2>
<form method="post" action="{{ url_for('admin.edit_item', id=item.id) }}" enctype="multipart/form-data">
<div class="form-group">
<label for="title">Item Title</label>
<input type="text" id="title" name="title" class="form-control" value="{{ item.title }}" required>
</div>
<div class="form-group">
<label for="description">Description</label>
<textarea id="description" name="description" class="form-control" rows="4" required>{{ item.description }}</textarea>
</div>
<div class="form-group">
<label for="price">Price ($)</label>
<input type="number" id="price" name="price" class="form-control" step="0.01" min="0" value="{{ item.price }}" required>
</div>
<div class="form-group">
<label for="category_id">Category</label>
<select id="category_id" name="category_id" class="form-control" required>
{% for category in categories %}
<option value="{{ category.id }}" {% if category.id == item.category_id %}selected{% endif %}>{{ category.name }}</option>
{% endfor %}
</select>
</div>
<div class="form-group">
<label for="status">Status</label>
<select id="status" name="status" class="form-control" required>
<option value="For Sale" {% if item.status == 'For Sale' %}selected{% endif %}>For Sale</option>
<option value="On Hold" {% if item.status == 'On Hold' %}selected{% endif %}>On Hold</option>
<option value="Sold" {% if item.status == 'Sold' %}selected{% endif %}>Sold</option>
</select>
</div>
<div class="form-group">
{% if item.image_filename %}
<p>Current image:</p>
<img src="{{ url_for('static', filename='uploads/' + item.image_filename) }}" alt="{{ item.title }}" style="max-width: 200px; max-height: 200px; margin-bottom: 1rem;">
{% endif %}
<label for="image">Change Item Image</label>
<input type="file" id="image" name="image" class="form-control">
<small>Optional. Leave empty to keep current image. Accepted formats: JPG, PNG, GIF</small>
</div>
<button type="submit" class="btn btn-primary">Update Item</button>
<a href="{{ url_for('admin.items') }}" class="btn" style="margin-left: 0.5rem;">Cancel</a>
</form>
{% endblock %}