You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi!
when I switched from {% for item in filed %} <label class="form-check-label" for="{{filed.auto_id}}">{{ item }}</label> {% endfor %}
to
<b><p><label for="{{filed.id_for_label}}">{{ filed.label }}</label></p></b> {% for value, text in filed.field.choices %} <label class="form-check-label" for="{{filed.auto_id}}_{{ forloop.counter0 }}"> <input type="radio" name="{{ filed.name }}" style="display:none" value="{{ value }}" id="{{filed.auto_id}}_{{ forloop.counter0 }}"> <span class="checkmark">{{ text }}</span> </label> {% endfor %}
In my template for editing previously stored data radio fields are not checked to indicate what data was stored when it was created.
this code is part of single_choice_radio_field.html
and it is used as such
{% include 'includes/single_choice_radio_field.html' with filed=flat_form.heating %}
The text was updated successfully, but these errors were encountered:
so long ago....
sorry I don't remember now and I have abandoned the project where it was used
temonuv
changed the title
When customizing template data stored in database is not taken (editing form)
When customizing template - data stored in database is not taken (editing form)
Sep 3, 2020
If want to edit the form and load the data saved on the database you must add to the input tag "{% if value in checked_values %} checked="checked"{% endif %}
Then save the values list in a variable on your views as checked_values and pass it to the template. return render(request, 'page.html', {'checked_values': values_list})
Hi!
when I switched from
{% for item in filed %}
<label class="form-check-label" for="{{filed.auto_id}}">{{ item }}</label>
{% endfor %}
to
<b><p><label for="{{filed.id_for_label}}">{{ filed.label }}</label></p></b>
{% for value, text in filed.field.choices %}
<label class="form-check-label" for="{{filed.auto_id}}_{{ forloop.counter0 }}">
<input type="radio" name="{{ filed.name }}" style="display:none" value="{{ value }}" id="{{filed.auto_id}}_{{ forloop.counter0 }}">
<span class="checkmark">{{ text }}</span>
</label>
{% endfor %}
In my template for editing previously stored data radio fields are not checked to indicate what data was stored when it was created.
this code is part of single_choice_radio_field.html
and it is used as such
The text was updated successfully, but these errors were encountered: