CuneiForm

จาก คูนิฟ็อกซ์ วิกิ

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

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:

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


Initiate

Design & Pre-made Scripts

Notable Sub-routines