{% extends "crud/form.html" %}
{% from "macros/form.html" import text_input, number_input, select, checkbox_list, readonly_field %}
{% set title = 'Edit Key' if is_update else 'Create Key' %}
{% block form_fields %}
{% if is_update %}
{{ readonly_field('Key', key.key, help='Key identifier cannot be changed') }}
{% else %}
{{ text_input('key', 'Key', value='', help='Leave empty to auto-generate a unique key', maxlength=16) }}
{% endif %}
{{ text_input('note', 'Description', value=(key.note or '') if key else '', maxlength=256) }}
{{ number_input('server_limit', 'Server Limit', value=key.server_limit if key else 0, help='Maximum number of servers (0 = unlimited)', min=0) }}
{{ select('feed', 'Feed', options=feeds, selected=key.feed if key else '', placeholder='main (default)') }}
{{ checkbox_list('products', 'Products', options=products, selected=key.products_list if key and key.products_list else [], help='Select which products this key can use') }}
{% endblock %}