Python wtforms.fields 模块,Field() 实例源码

我们从Python开源项目中,提取了以下5个代码示例,用于说明如何使用wtforms.fields.Field()

项目:eq-survey-runner    作者:ONSdigital    | 项目源码 | 文件源码
def test_text_area_a_wtforms_field(self):
        text_area = MaxTextAreaField('LabelText', _form=self.mock_form, _name='aName')
        self.assertIsInstance(text_area, Field)
项目:eq-survey-runner    作者:ONSdigital    | 项目源码 | 文件源码
def test_text_area_supports_maxlength_property(self):
        text_area = MaxTextAreaField('TestLabel', maxlength=20, _form=self.mock_form, _name='aName')
        self.assertIsInstance(text_area, Field)
        self.assertEqual(text_area.maxlength, 20)
项目:eq-survey-runner    作者:ONSdigital    | 项目源码 | 文件源码
def test_integer_field(self):
        integer_field = CustomIntegerField(_form=self.mock_form, _name='aName')
        self.assertIsInstance(integer_field, Field)

        try:
            integer_field.process_formdata(['NonInteger'])
        except:
            self.fail("Exceptions should not thrown by CustomIntegerField")
项目:eq-survey-runner    作者:ONSdigital    | 项目源码 | 文件源码
def test_decimal_field(self):
        decimal_field = CustomDecimalField(_form=self.mock_form, _name='aName')
        self.assertIsInstance(decimal_field, Field)

        try:
            decimal_field.process_formdata(['NonDecimal'])
        except:
            self.fail("Exception should not be thrown by CustomDecimalField")
项目:railgun    作者:xin-xinhanggao    | 项目源码 | 文件源码
def _init_form_helper(self, form, lock_fields):
        """General :meth:`init_form` helper utility to remove all fields
        in `lock_fields`.

        :param form: The :class:`flask_wtf.Form` instance.
        :param lock_fields: :class:`list` of field names to be removed.
        """
        for k, v in form.__dict__.items():
            if isinstance(v, Field) and not isinstance(v, HiddenField):
                if k in lock_fields:
                    del form[k]