<main class="bd-main order-1">

{% extends '_nav.html' %}
{% import "bootstrap/wtf.html" as wtf %}

{% block content %}

<div class="container">
  <div class="row pb-5">
	      <div class="col-md-10 col-lg-20 mx-lg-auto mx-md-auto" style="left: -60px;bottom: -65px;">
		<button type="button" class="btn btn-outline-secondary" onclick="history.back()">
			<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-chevron-left" viewBox="0 0 16 16">
			  <path fill-rule="evenodd" d="M11.354 1.646a.5.5 0 0 1 0 .708L5.707 8l5.647 5.646a.5.5 0 0 1-.708.708l-6-6a.5.5 0 0 1 0-.708l6-6a.5.5 0 0 1 .708 0z"></path>
			</svg>
		<span class="visually-hidden">Button</span>
		</button>
	</div>
      <div class="shadow col-md-10 col-lg-8 mx-lg-auto mx-md-auto border border-2 bg-light">
		      {% include '_nav_top.html' %}


		<!-- ----- start edit childToEdit content ----- -->
		        <ul style="padding-top: 10px;">
			<br>
        </ul>

		<!-- links -->


		<!-- show flash - based on WTForms validators
			 see https://pythonprogramming.net/flash-flask-tutorial/
			 get_flashed_messages() exists here because of flash()
			 in the route function
			 -->
			 {% with errors = get_flashed_messages() %}
				 {% if errors %}
					 {% for err in errors %}
					 <div class="alert alert-danger alert-dismissible" role="alert">
						 <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
						 {{ err }}
					 </div>
					 {% endfor %}
				 {% endif %}
			 {% endwith %}
		<!-- end of flash -->

		<!-- start form for editing record
			 correct use of WTF Bootstrap static -->
		<form method="post" action="{{ url_for('children_bp.edit_child_result') }}" id="update">
			{{ form1.csrf_token }}
			{{ form1.uuid_field(value=childToEdit.uuid) }}
			{{ wtf.form_field(form1.firstname, value=childToEdit.firstname) }}
			{{ wtf.form_field(form1.lastname, value=childToEdit.lastname) }}
			{{ wtf.form_field(form1.family_uuid, value=childToEdit.family_uuid) }}
			{{ wtf.form_field(form1.date_of_birth, value=childToEdit.date_of_birth) }}
			{{ wtf.form_field(form1.date_of_registration, value=childToEdit.date_of_registration) }}
			{{ wtf.form_field(form1.class1_uuid, value=childToEdit.class1_uuid) }}
			{{ wtf.form_field(form1.class2_uuid, value=childToEdit.class2_uuid) }}
			{{ wtf.form_field(form1.class3_uuid, value=childToEdit.class3_uuid) }}
			{{ wtf.form_field(form1.submit, button_map={'submit':'success'}) }}
		</form>
		</div>
	</div>
	<script>
		Collapse("Children")
		setCurrentValue('family_uuid', "{{ childToEdit['family_uuid'] }}")
		setCurrentValue('class1_uuid', "{{ childToEdit['class1_uuid'] }}")
		setCurrentValue('class2_uuid', "{{ childToEdit['class2_uuid'] }}")
		setCurrentValue('class3_uuid', "{{ childToEdit['class3_uuid'] }}")
	</script>
</div>

{% endblock %}
</main>