dimanche 20 septembre 2015

Bug with checkboxes in django-forms

I was going to create form in templates by yourself and I got problem with switch-checkbox. No matter checkbox is true or false, it anyway show me false. enter image description here

So, my html-code looks so:

        <form action="." method="POST" enctype="multipart/form-data">{% csrf_token %}
            <table>
                <tr>
                <td>
                    {{ form.subject.errors }}
                    <label for="{{ form.name.id_for_label }}">Name:</label>
                    {{ form.name }}
                </td>
                </tr>
                <tr>
                <td>
                    {{ form.subject.errors }}
                    <label for="{{ form.description.id_for_label }}">Description:</label>
                    {{ form.description }}
                </td>
                </tr>
                <tr>
                <td>
                    {{ form.subject.errors }}
                    <label for="{{ form.is_visible.id_for_label }}">Is visible:</label>
                    <div class="switch">
                        <label>
                            False
                            <input type="checkbox" id="is_visible" name="is_visible" value="{{ form.is_visible }}">
                            <span class="lever"></span>
                            True
                        </label>
                    </div>
                </td>
                </tr>
            </table>
            <button class="waves-effect waves-light btn blue-grey darken-1" type="submit">Save changes</button>
        </form>

What must I do for getting right value for checkbox? + as you see after False label appeared ">, what is it? Thank you, for your attention.




Aucun commentaire:

Enregistrer un commentaire