1,844
การแก้ไข
ล (→Know Thy Self) |
|||
| บรรทัดที่ 228: | บรรทัดที่ 228: | ||
==== Sequence and Column Names ==== | ==== Sequence and Column Names ==== | ||
These few attributes govern the navigation, submission, and database-mapping of the form: | |||
* '''seq''' ''([str,])'': Field names as defined via WTForms. Its order dictates the tab-sequence of the form on the client-side. If there is not given an overriding list, the initiation routine automatically generates this list from FlaskForm. | |||
* '''cnames''' ''([str,])'': Field names as matched with corresponding database model. If no value is given, the list copies from {{code|seq}}. (See notes.) | |||
* '''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. | |||
==== Getting Data ==== | ==== Getting Data ==== | ||