Python Forum
Flask: editing a submitted form - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Web Scraping & Web Development (https://python-forum.io/forum-13.html)
+--- Thread: Flask: editing a submitted form (/thread-37405.html)



Flask: editing a submitted form - test - Jun-06-2022

Hi!
I am making a form which has a many fields. Some are radio buttons and dropdowns. Once i store the value of the input in my database, how can i make it so that the state of the radiobutton and dropdown is updated when i click on edit page?

I have tried this, but it does not work:
                    <div class="form-row">
                        <div class="col-12">
                        <label for="tr_level">Level</label>
                        <select name="tr_level" value="{{ pt_update.tr_level }}" class="form-control">
                            <option>I A</option>
                            <option>II B</option>
                            <option>III C</option>
                            <option>IV D</option>
                            <option>V E</option>
                        </select></div>
I have not been able to find a way to update the radio-button state..
Have been stuck here for quite a bit. Any help would be very useful! Thanks.


RE: Flask: editing a submitted form - test - Jun-07-2022

This helped: https://stackoverflow.com/questions/29451208/set-default-value-for-select-html-element-in-jinja-template