<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Add an Item</title> </head> <body> <h2 align="center">Add new Item</h2> <!-- Display error message if any --> {% if error %} <p>{{ error }}</p> {% endif %} <!-- Form for adding a new item --> <form method="POST"> {% for attrib in item_attributes -%} <p> <label for="{{ attrib.attrib_name }}">{{ attrib.display_name }}:</label> {% if attrib.html_input_type == "select" %} <!-- Render a dropdown for select attributes --> <select id="{{ attrib.attrib_name }}" name="{{ attrib.attrib_name }}" {% if attrib.required %} required {% endif %} > {% for option in attrib.options -%} <option value="{{ option }}">{{ option }}</option> {% endfor %} </select> {% else %} <!-- Render an input field for other attributes --> <input id="{{ attrib.attrib_name }}" type="{{ attrib.html_input_type }}" name="{{ attrib.attrib_name }}" {% if attrib.required %} required {% endif %} {% if attrib.html_input_type == "number" %} {% if attrib.min_val is not none %} min="{{ attrib.min_val }}" {% endif %} {% if attrib.max_val is not none %} max="{{ attrib.max_val }}" {% endif %} {% endif %} {% if attrib.default_val is not none %} value="{{ attrib.default_val }}" {% endif %} /> {% endif %} </p> {% endfor %} <p><input type="submit" value="Submit" /></p> <button type="button" onclick="window.location.href='/'">Cancel</button> </form> </body> </html>