{% set form = guest.formbuilder_get({ "id": order.form_id }) %}
{% set config = order.config %}
<form class="api-form"  action="{{ 'api/admin/order/update_config'|link }}" data-api-msg="Order was updated">
        <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 }}" />

        {% for field in form.fields %}
        <div class="rowElem">
            {% if field.hide_label!=1 %}<label for="{{ field.name }}">{{ field.label }}</label>{% endif %}
            <div class="formRight">
                {% if field.type == "text" %}
                        <input type="text" name="config[{{ field.name }}]" value="{{ (order.config[field.name])}}"
                {% if field.required==1 %}required="required"{% endif %}
                {% if field.readonly==1%}readonly="readonly"{% endif %}
                style="height: 20px; width: 30%;"
                />
                {% elseif field.type == "select" %}
                <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="checkbox" style="padding-right: 20px"><input type="checkbox" name="config[{{field.name}}][]" value="{{v}}"
                    {% if v in config[field.name] %}checked="checked"{% endif %})"
                    style="margin-right: 10px;"
                        />{{k}}
                    </label>
                    {% endfor %}

                {% elseif field.type == "radio" %}
                {% for k,v in field.options %}
                <label class="radio" style="padding-right: 20px">
                    <input type="radio" name="config[{{field.name}}]" value="{{v}}"
                    {% if attribute (order.config, field.name) == v %}checked{% endif %}
                    style="margin-right: 10px;"
                    />
                    {{k}}
                </label>
                {% endfor %}

                {% elseif field.type == "textarea" %}
                <div style="width: auto; max-width:50%;">
                    <textarea id="{{field.name}}" name="config[{{ field.name }}]" style="width: {{ field.options.width }}px; height: {{ field.options.height }}px; overflow: scroll;"
                        {% if field.required==1 %}required="required"{% endif %}
                        {% if field.readonly==1%}readonly="readonly"{% endif %}
                    >{{ attribute (order.config, field.name)}}</textarea>
                </div>
                {% endif %}
                </div>
            <div class="fix"></div>
        </div>
        {% endfor %}

        <input type="hidden" name="id" value="{{ order.id }}" />
        <div class="rowElem">
            <label></label>
            <div class="formRight">
                <button type="submit" class="btn blueBtn pull-right">{{ 'Update'|trans }}</button>
            </div>
            <div class="fix"></div>
        </div>
</form>

<script type="text/javascript">
    $(function () {
        $("form").submit( function () {
                $(':checkbox:not(:checked)').removeAttr('checked');
            }
        )
    });
</script>
