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

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

เพิ่มขึ้น 1,354 ไบต์ ,  5 เมษายน 2567
ไม่มีคำอธิบายอย่างย่อ
(สร้างหน้าด้วย "== Define == == Initiate == == Design & Pre-made Scripts == == Notable Sub-routines ==")
 
ไม่มีความย่อการแก้ไข
บรรทัดที่ 1: บรรทัดที่ 1:
CuneiForm type objects are powered by WTForms engine. However, this object type also introduce a handful of additional variables and attributes to strike a sweet balance between ease of development and flexibility.
== Define ==
== Define ==
Defining a CuneiForm is essentially similar to declaring a WTForm. There are no differences in declaring fields, validations, render keywords, and validating functions. (There exist a few special functions that can dynamically generate some common fields, but we'll leave that to a later section.)
Let's first have a quick look at a very basic CuneiForm:
<syntaxhighlight lang="python" line="1">
class LoginForm(FlaskForm, CuneiForm):
    company = StringField(lazy_gettext("Company"), validators=[InputRequired(lazy_gettext("Required!"))])
    username = StringField(lazy_gettext("Username"), validators=[InputRequired(lazy_gettext("Required!"))])
    password = PasswordField(lazy_gettext("Password"), validators=[InputRequired(lazy_gettext("Required!"))])
    clear_session = BoolField(lazy_gettext("Log-out of other sessions"), default=True)
    submit = SubmitField(lazy_gettext("Log-in"))
    def validate_company(self, company):
        # Validation goes here
    def validate_username(self, username):
        # Validation goes here
    def validate_password(self, password):
        # Validation goes here
</syntaxhighlight>


== Initiate ==
== Initiate ==