<h3 class="font-bold text-lg">Feld bearbeiten: {{ field.name }}</h3>
<button onclick="closeModal()" class="btn btn-sm btn-circle btn-ghost absolute right-2 top-2">✕</button>

    {% if warning %}
    <div role="alert" class="alert alert-warning mt-4">
        <svg xmlns="http://www.w3.org/2000/svg" class="stroke-current shrink-0 h-6 w-6" fill="none" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z" /></svg>
        <span>{{ warning }}</span>
    </div>
    {% endif %}

    <form hx-post="/record/{{ doc_id }}/update-field" hx-target="#row-{{ field.name }}" hx-swap="outerHTML" class="py-4 space-y-4">
        <input type="hidden" name="field_name" value="{{ field.name }}">
        <input type="hidden" name="is_multi_valued" value="{{ 'true' if field.get('multiValued') else 'false' }}">

        {% if field.get('multiValued') %}
            <div class="form-control">
                <label class="label" for="field_value">
                    <span class="label-text">Werte (ein Wert pro Zeile)</span>
                </label>
                <textarea name="field_value" id="field_value" class="textarea textarea-bordered h-32">{%- if doc_value is iterable and doc_value is not string -%}
                        {{- doc_value|join('\n') -}}
                    {%- else -%}
                        {{- doc_value or '' -}}
                    {%- endif -%}
                </textarea>
            </div>
        {% else %}
            <div class="form-control">
                <label class="label" for="field_value">
                    <span class="label-text">Wert</span>
                </label>
                <input type="text" name="field_value" id="field_value" value="{{ doc_value or '' }}" class="input input-bordered w-full">
            </div>
        {% endif %}

        <div class="modal-action">
            <button type="button" onclick="closeModal()" class="btn btn-ghost">Abbrechen</button>
            <button type="submit" class="btn btn-primary">Speichern</button>
        </div>
    </form>
