<commit_before><h1>Product creation</h1>

<form action="{{ path('monmagasin_mesproduits_create') }}" method="post" {{ form_enctype(form) }}>
    {{ form_row(form.name) }}
	{{ form_row(form.description) }}
	{{ form_row(form.price_kg) }}
	{{ form_row(form.active) }}
	{{ form_row(form.promo_active) }}
	{{ form_row(form.promo_price) }}
	{{ form_row(form.promo_expire_date) }}
	{{ form_row(form.promo_percentage) }}
	{{ form_row(form.file) }}

	<h3>Prices</h3>
    <ul class="prices" data-prototype="{{ form_widget(form.prices.vars.prototype)|e }}">
        {# iterate over each existing tag and render its only field: name #}
        {% for price in form.prices %}
            <li>{{ form_row(price.price) }}</li>
        {% endfor %}
    </ul>

    {{ form_rest(form) }}

    <p>
        <button type="submit">Create</button>
    </p>
</form>

<ul class="record_actions">
    <li>
        <a href="{{ path('monmagasin_mesproduits') }}">
            Back to the list
        </a>
    </li>
</ul>

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js"></script>

<script type="text/javascript"><!--

// Get the div that holds the collection of prices 
var collectionHolder = $('ul.prices');

// setup an "add a tag" link
var $addTagLink = $('<a href="#" class="add_price_link">Add a Price</a>');
var $newLinkLi = $('<li></li>').append($addTagLink);

jQuery(document).ready(function() {
    // add the "add a tag" anchor and li to the tags ul
    collectionHolder.append($newLinkLi);

    $addTagLink.on('click', function(e) {
        // prevent the link from creating a "#" on the URL
        e.preventDefault();

        // add a new tag form (see next code block)
        addTagForm(collectionHolder, $newLinkLi);
    });
});

function addTagForm(collectionHolder, $newLinkLi) {
    // Get the data-prototype we explained earlier
    var prototype = collectionHolder.attr('data-prototype');
	console.log(prototype);
    // Replace '__name__' in the prototype's HTML to
    // instead be a number based on the current collection's length.
    var newForm = prototype.replace(/__price__/g, collectionHolder.children().length);

    // Display the form in the page in an li, before the "Add a tag" link li<commit_msg>Gestion du bug avec plusieurs prices<commit_after><h1>Product creation</h1>

<form action="{{ path('monmagasin_mesproduits_create') }}" method="post" {{ form_enctype(form) }}>
    {{ form_row(form.name) }}
	{{ form_row(form.description) }}
	{{ form_row(form.price_kg) }}
	{{ form_row(form.active) }}
	{{ form_row(form.promo_active) }}
	{{ form_row(form.promo_price) }}
	{{ form_row(form.promo_expire_date) }}
	{{ form_row(form.promo_percentage) }}
	{{ form_row(form.file) }}

	<h3>Prices</h3>
    <ul class="prices" data-prototype="{{ form_widget(form.prices.vars.prototype)|e }}">
        {# iterate over each existing tag and render its only field: name #}
        {% for price in form.prices %}
            <li>{{ form_row(price.price) }}</li>
        {% endfor %}
    </ul>

    {{ form_rest(form) }}

    <p>
        <button type="submit">Create</button>
    </p>
</form>

<ul class="record_actions">
    <li>
        <a href="{{ path('monmagasin_mesproduits') }}">
            Back to the list
        </a>
    </li>
</ul>

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js"></script>

<script type="text/javascript"><!--

// Get the div that holds the collection of prices 
var collectionHolder = $('ul.prices');

// setup an "add a tag" link
var $addTagLink = $('<a href="#" class="add_price_link">Add a Price</a>');
var $newLinkLi = $('<li></li>').append($addTagLink);

jQuery(document).ready(function() {
    // add the "add a tag" anchor and li to the tags ul
    collectionHolder.append($newLinkLi);

    $addTagLink.on('click', function(e) {
        // prevent the link from creating a "#" on the URL
        e.preventDefault();

        // add a new tag form (see next code block)
        addTagForm(collectionHolder, $newLinkLi);
    });
});

function addTagForm(collectionHolder, $newLinkLi) {
    // Get the data-prototype we explained earlier
    var prototype = collectionHolder.attr('data-prototype');
	console.log(prototype);
    // Replace '__name__' in the prototype's HTML to
    // instead be a number based on the current collection's length.
    var newForm = prototype.replace(/__name__/g, collectionHolder.children().length);

    // Display the form in the page in an li, before the "Add a tag" link li
{'fraction_non_alphanumeric': 0.16674097191261703, 'fraction_numerical': 0.003120820329915292, 'mean_word_length': 3.3904109589041096, 'pattern_counts': {'":': 0, '<': 59, '<?xml version=': 0, '>': 57, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3954704', 'n_tokens_mistral': 1496, 'n_tokens_neox': 1459, 'n_words': 362}