{% set form = guest.formbuilder_get({ "id": order.form_id }) %}
{% set config = order.config %}
<form class="api-form" method="post" action="{{ 'api/admin/order/update_config'|link }}" data-api-msg="Order was updated">
    <input type="hidden" name="CSRFToken" value="{{ CSRFToken }}"/>
    <input type="hidden" name="config[form_id]" value="{{ config.form_id }}"/>
    <input type="hidden" name="config[id]" value="{{ config.id }}"/>
    <input type="hidden" name="config[product_id]" value="{{ form.product_id }}"/>
    <input type="hidden" name="config[type]" value="{{ config.type }}"/>
    <input type="hidden" name="config[quantity]" value="{{ config.quantity }}"/>
    <input type="hidden" name="config[price]" value="{{ config.price }}"/>
    <input type="hidden" name="config[setup_price]" value="{{ config.setup_price }}"/>
    <input type="hidden" name="config[discount]" value="{{ config.discount }}"/>
    <input type="hidden" name="config[discount_price]" value="{{ config.discount_price }}"/>
    <input type="hidden" name="config[discount_setup]" value="{{ config.discount_setup }}"/>
    <input type="hidden" name="config[total]" value="{{ config.total }}"/>
    <input type="hidden" name="id" value="{{ order.id }}"/>

    <div class="card-body">
        <div class="row">
            <div class="col-12">
                {% for field in form.fields %}
                    <div class="mb-3 row">
                        <div class="col-md-3">
                            {% if field.hide_label!=1 %}
                                <label class="col-form-label {% if field.required == 1 %}required{% endif %}"
                                       for="{{ field.name }}">{{ field.label }}</label>
                            {% endif %}
                        </div>
                        <div class="col-md-6">
                            {% if field.type == "text" %}
                                <div class="input-group">
                                    {% if field.prefix %}
                                        <span class="input-group-text">{{ field.prefix }}</span>
                                    {% endif %}
                                    <input class="form-control readonly" type="text"
                                           name="config[{{ field.name }}]" id="{{ field.name }}"
                                           value="{{ (order.config[field.name]) }}"
                                           {% if field.required %}required="required"{% endif %}
                                        {% if field.readonly %}readonly="readonly"{% endif %}>
                                    {% if field.suffix %}
                                        <span class="input-group-text">{{ field.suffix }}</span>
                                    {% endif %}
                                </div>
                            {% elseif field.type == "select" %}
                                <select id="{{ field.name }}" class="form-select" name="config[{{ field.name }}]"
                                        required="required">
                                    {% for k,v in field.options %}
                                        <option value="{{ v }}"
                                                {% if v == attribute (order.config, field.name) %}selected="selected"{% endif %}>{{ k }}</option>
                                    {% endfor %}
                                </select>

                            {% elseif field.type == "checkbox" %}
                                {% for k,v in field.options %}
                                    <label class="form-check form-check-inline">
                                        <input id="{{ field.name }}" class="form-check-input" type="checkbox"
                                               name="config[{{ field.name }}][]"
                                               value="{{ v }}"
                                               {% if v in config[field.name] %}checked="checked" {% endif %}>
                                        <span class="form-check-label">{{ k }}</span>
                                    </label>
                                {% endfor %}

                            {% elseif field.type == "radio" %}
                                {% for k,v in field.options %}
                                    <label class="form-check form-check-inline">
                                        <input id="{{ field.name }}" class="form-check-input" type="radio"
                                               name="config[{{ field.name }}]" value="{{ v }}"
                                               {% if attribute (order.config, field.name) == v %}checked{% endif %}>
                                        <span class="form-check-label">{{ k }}</span>
                                    </label>
                                {% endfor %}

                            {% elseif field.type == "textarea" %}
                                <textarea class="form-control" rows="5"
                                          name="config[{{ field.name }}]"
                                          id="{{ field.name }}"
                                          {% if field.required==1 %}required="required"{% endif %}
                                    {% if field.readonly==1 %}readonly="readonly"{% endif %}>{{ attribute (order.config, field.name) }}</textarea>
                            {% endif %}
                        </div>
                    </div>
                {% endfor %}
            </div>
        </div>
    </div>
    <div class="card-footer text-end">
        <button type="submit" class="btn btn-primary pull-right">{{ 'Update'|trans }}</button>
    </div>
</form>
