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

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

{% block content %}
    {% form_theme form "SensioDistributionBundle::Configurator/form.html.twig" %}
    {% include "SensioDistributionBundle::Configurator/steps.html.twig" with { "index": index, "count": count } %}

    <h1>Global Secret</h1>
    <p>Configure the global secret for your website (the secret is used for the CSRF protection among other things):</p>

    {{ form_errors(form) }}
    <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 class="symfony-button-grey" href="#" onclick="generateSecret(); return false;">Generate</a>
                <div class="symfony-form-errors">
                    {{ form_errors(form.secret) }}
                </div>
            </div>
        </div>

        {{ form_rest(form) }}

        <div class="symfony-form-footer">
            <p><input type="submit" value="Next Step" class="symfony-button-grey" /></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>
{% endblock %}
