{% extends "common/auth_page.twig" %}

{% block contentTitle %}{{'edition-product'|trans}}{% endblock %}

{% block content %}

	<form action="{{path_for(constant('GestionComedor\\Configuration\\Routers\\ProductRouters::PRODUCT_SAVE'))}}" method="POST" >
	  <input type="hidden" class="form-control" name="productId" value="{{product.id}}" />
	  <div class="row">
			<div class="form-group col-md-6">
				<label for="principalName" class="font-weight-bold" >{{'principal'|trans}}</label>
				<input type="input" class="form-control" name="principalName" value="{{product.principalName}}" required>
			</div>

			<div class="form-group col-md-6">
				<label for="secondaryName" class="font-weight-bold" >{{'accompaniment'|trans}}</label>
				<input type="input" class="form-control" name="secondaryName" value="{{product.secondaryName}}" >
			</div>
		</div>

		<div class="row">
			<div class="form-group col-md-6">
				<label for="categoryProduct" class="font-weight-bold" >{{'category'|trans}}</label>

	  		<select name="categoryProduct" id="categoryProduct" class="form-control">
	  			{% for categoryProduct in categoryProducts %}
	  				<option value="{{categoryProduct.id}}" {% if categoryProduct.id == product.categoryProductId %} selected {% endif %} >{{categoryProduct.name}}</option>
		  		{% endfor %}
	  			
	  		</select>


			</div>
		</div>

		{% for allergen in allergens %}
			<li>
			  <input type="checkbox" class="form-check-input" id="allergen-{{allergen.id}}" name="allergens[]" value="{{allergen.id}}"
				{% for allergenProduct in allergenProducts %}
					{% if allergenProduct.allergenId == allergen.id %}
						checked
					{% endif %}
				{% endfor %}
			  >
  			<label class="form-check-label" for="allergen-{{allergen.id}}">{{allergen.code}} {{allergen.name}}</label>
  		</li>

		{% endfor %}

		<div class="row">
			<div class="form-group col-md-2 pt-4">
				<button type="submit" class="btn btn-primary">{{'save'|trans}}</button>
			</div>
		</div>

	</form>

{% endblock %}


