{% extends "crud/form.html" %}
{% from "macros/form.html" import text_input, checkbox, textarea %}
{% set title = 'Edit User' if is_update else 'Create User' %}
{% block form_fields %}
{% if is_update %}
{{ text_input('username', 'Username', value=user.username, maxlength=64) }}
{{ text_input('password', 'Password', type='password', help='Leave empty to keep current password') }}
{% else %}
{{ text_input('username', 'Username', required=true, maxlength=64) }}
{{ text_input('password', 'Password', type='password', required=true, help='Minimum ' ~ min_password_length ~ ' characters') }}
{% endif %}
{{ textarea('description', 'Description', value=(user.description or '') if user else '') }}
{{ checkbox('readonly', 'Read-only access', id='readonly', checked=user.readonly if user else false) }}
{% endblock %}