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

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

เพิ่มขึ้น 1,909 ไบต์ ,  5 เมษายน 2567
บรรทัดที่ 64: บรรทัดที่ 64:
** '''{{code|lang=python|'right'}}''': Normal string field whose text is aligned right rather than the normal left.
** '''{{code|lang=python|'right'}}''': Normal string field whose text is aligned right rather than the normal left.
** '''{{code|lang=python|'color'}}''': String field with an associated color selector element.
** '''{{code|lang=python|'color'}}''': String field with an associated color selector element.
=== Instant Calculation ===
Instant calculation function within CuneiForms, or 'instacalc', allows a change in one form field to initiate a small calculation request to the server and update other affected fields based on the calculation result. It is specified in the variable {{code|MASTER_instacalc}} under form definition.
<syntaxhighlight lang="python">
MASTER_instacalc = [(str trigger_fld0, [
                                          route0,
                                          [str collect_fld00, str collect_fld01, ...],
                                          [str result_fld00, str result_fld01, ...]]),
                                          ...
                                      ]),
                  [(str trigger_fld1, [
                                          route1,
                                          [str collect_fld10, str collect_fld11, ...],
                                          [str result_fld10, str result_fld11, ...]]),
                                          ...
                                      ]),
                    ...]
# Example from Accounting Journal's withholding tax form
MASTER_instacalc = [("amt", ["cunei_gl.calcwht", ["amt", "rate"], ["tax"]]),
                    ("rate", ["cunei_gl.calcwht", ["amt", "rate"], ["tax"]]),
                    ...]
</syntaxhighlight>
* '''trigger_fldX''' is the field whose value change will trigger the instacalc routine.
* '''routeX''' can be either:
** A ''string'' similar to the string argument fed to Flask's {{code|url_for}}.
** A ''dict'' of format {{code|lang=python|{'route': str route_name, **kwargs} }}, where {{code|kwargs}} represents arguments to be fed to the instacalc route.
* '''collect_fldXY''' are the fields whose values are collected and used in calculation routine.
=== Auto-numbering Function ===
=== Other Form Definition Variables ===
MASTER_firstonly


== Initiate ==
== Initiate ==