{% extends "SensioDistributionBundle::Configurator/layout.html.twig" %}

{% block title %}Symfony - Configure global Secret{% endblock %}

{% block content %}
    {% form_theme form "SensioDistributionBundle::Configurator/form.html.twig" %}

    <div class="step">
        {% include "SensioDistributionBundle::Configurator/steps.html.twig" with { "index": index, "count": count } %}

        <h1>Global Secret</h1>
        <p>Configure the global secret for your website:</p>

        <div class="symfony-form-errors">
            {{ form_errors(form) }}
        </div>
        <form action="{{ path('_configurator_step', { 'index': index }) }} " method="POST">
            <div class="symfony-form-row">
                {{ form_label(form.secret) }}
                <div class="symfony-form-field">
                    {{ form_widget(form.secret) }}
                    <a href="#" onclick="generateSecret(); return false;" class="sf-button">
                        <span class="border-l">
                            <span class="border-r">
                                <span class="btn-bg">Generate</span>
                            </span>
                        </span>
                    </a>
                    <div class="symfony-form-errors">
                        {{ form_errors(form.secret) }}
                    </div>
                </div>
            </div>

            {{ form_rest(form) }}

            <div class="symfony-form-footer">
                <p>
                    <button type="submit" class="sf-button">
                        <span class="border-l">
                            <span class="border-r">
                                <span class="btn-bg">NEXT STEP</span>
                            </span>
                        </span>
                    </button>
                </p>
                <p>* mandatory fields</p>
            </div>

        </form>

        <script type="text/javascript">
            function generateSecret()
            {
                var result = '';
                for (i=0; i < 32; i++) {
                    result += Math.round(Math.random()*16).toString(16);
                }
                document.getElementById('distributionbundle_secret_step_secret').value = result;
            }
        </script>
    </div>
{% endblock %}
