blob: 7c47569f1b1feea09ab16cf49d2f2d6a45051e3b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
{% extends "config_bundle/steps/table_formset.html" %}
{% load bootstrap4 %}
{% block table %}
<thead>
<tr>
<th>Device</th>
<th>Image</th>
<th>HeadNode</th>
</tr>
</thead>
<tbody>
{% for form in formset %}
<tr>
<td>{% bootstrap_field form.host_name show_label=False %}</td>
<td>{% bootstrap_field form.image show_label=False %}</td>
<td class="table_hidden_input_parent">
<input id="radio_{{forloop.counter}}" class="my_radio" type="radio" name="headnode" value="{{forloop.counter}}">
{{ form.headnode }}
</td>
</tr>
{% endfor %}
{{formset.management_form}}
{% endblock table %}
{% block tablejs %}
<script>
document.getElementById("radio_{{headnode}}").checked = true;
</script>
{% endblock tablejs %}
{% block onleave %}
var parents = document.getElementsByClassName("table_hidden_input_parent");
for(var i=0; i<parents.length; i++){
var node = parents[i];
var radio = node.getElementsByClassName("my_radio")[0];
var checkbox = radio.nextElementSibling;
if(radio.checked){
checkbox.value = "True";
}
}
|