Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
temonuv opened this issue Oct 18, 2018 · 3 comments

Comments

@temonuv
Copy link

temonuv commented Oct 18, 2018

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 %}
@CARocha
Copy link

CARocha commented Sep 3, 2020

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

@temonuv
Copy link
Author

temonuv commented Sep 3, 2020

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

@temonuv 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
@Abcaran
Copy link

Abcaran commented Nov 7, 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})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants