django-multiselectfield icon indicating copy to clipboard operation
django-multiselectfield copied to clipboard

When customizing template - data stored in database is not taken (editing form)

Open temonuv opened this issue 6 years ago • 3 comments

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 %}

temonuv avatar Oct 18 '18 08:10 temonuv

@temonuv i have the same problem! how to resolve? inside admin working but is forms outside show empty select input

CARocha avatar Sep 03 '20 04:09 CARocha

so long ago.... sorry I don't remember now and I have abandoned the project where it was used

temonuv avatar Sep 03 '20 06:09 temonuv

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})

Abcaran avatar Nov 07 '20 14:11 Abcaran