ข้ามไปเนื้อหา

ผลต่างระหว่างรุ่นของ "CuneiForm"

เพิ่มขึ้น 1,095 ไบต์ ,  8 เมษายน 2567
บรรทัดที่ 233: บรรทัดที่ 233:
* '''submit_id''' ''(str: defaults to {{code|lang=python|'submit'}})'':
* '''submit_id''' ''(str: defaults to {{code|lang=python|'submit'}})'':


The lists {{code|seq}} and {{code|cnames}} work together to create a mapping key. In other words, data entered through the form field {{code|lang=python|seq[i]}} is written to database column {{code|lang=python|cnames[i]}} and vice-versa for reading operations. '''DO NOTE THAT''', under most use case, {{code|seq}} and {{code|cnames}} both hold the same values. Assigning different values to {{code|seq}} and {{code|cnames}} is legitimate in some use cases. However, the rarity of such cases can make the code harder to parse by future developers. A more recommended way to achieve similar result is to explicitly assign values to appropriate columns/keys during data manipulation.
The lists {{code|seq}} and {{code|cnames}} work together to create a mapping key. In other words, data entered through the form field {{code|lang=python|seq[i]}} is written to database column {{code|lang=python|cnames[i]}} and vice-versa for reading operations. '''DO NOTE THAT''', under most use cases, {{code|seq}} and {{code|cnames}} both hold the same values. Assigning different values to {{code|seq}} and {{code|cnames}} is legitimate in some use cases. However, the rarity of such cases can make the code harder to parse by future developers. A more recommended way to achieve similar result is to explicitly assign values to appropriate columns/keys during data manipulation.


==== Getting Data ====
==== Getting Data ====
By default, a CuneiForm only displays either the default values (as specified during form definition) or the values fed explicitly before the page is sent. Once the page components are loaded, the form can then ask for data from the server in a separate HTML request. These attributes below dictate the form's behaviours regarding data request:
* '''populate_route''' ''(url_for_string)''
* '''populate_suppress''' ''([str,])''
* '''populate_id''' ''([str,])''


==== Sending Data ====
==== Sending Data ====
Normal submission behaviour of a FlaskForm is to send a POST request to the same currently displaying route, then the page is refreshed. This approach, although neat and clean, creates a choppy experience for users. CuneiFox offers a way to override this behaviour using the following attributes:
* '''post_route''' ''(url_for_string)''
* '''redirect''' ''(bool)''
Sometimes, a form submission is followed by a long, thread-based operation. More attributes are needed to dictate the thread-tracking behaviours.
* '''wait_long_process''' ''(bool)''
* '''track_route''' ''(url_for_string)''
* '''wait_redirect''' ''(url_for_string)''


== Design & Pre-made Scripts ==
== Design & Pre-made Scripts ==