我们从Python开源项目中,提取了以下27个代码示例,用于说明如何使用wtforms.fields.HiddenField()。
def _is_hidden(field): """Detect if the field is hidden.""" if isinstance(field, HiddenField): return True if isinstance(field.widget, HiddenInput): return True return False
def is_hidden_field_filter(field): return isinstance(field, HiddenField)
def jenkins_form_factory(*args, **kwargs): attributes = dict\ ( signature = fields.HiddenField\ () , view = fields.SelectField\ ( u'???' , choices=JenkinsViewChoices() , default=None ) , parent = InlineFieldList\ ( InlineFormField ( ParentForm ) , label=u'????????' , description=u'??????? ???????????? ?????' , validators= [ validators.DataRequired() , ] ) , node = fields.SelectField\ ( u'????' , choices=JenkinsNodeChoices() , validators= [ validators.DataRequired() , ] ) , config = fields.StringField\ ( u'???????? ??????' , widget=ReadonlyTextArea() ) ) form_instance = type('Form', (form.Form, ), attributes)(*args, **kwargs) if form_instance.parent.data: attributes['param'] = InlineFormField\ ( jenkins_param_form_factory(form_instance) , u'?????????' ) kwargs['csrf_enabled'] = False return type('Form', (form.Form, ), attributes)(*args, **kwargs)
def register_template_utils(app): """Register Jinja 2 helpers (called from __init__.py).""" @app.template_test() def equalto(value, other): return value == other @app.template_global() def is_hidden_field(field): from wtforms.fields import HiddenField return isinstance(field, HiddenField) app.add_template_global(index_for_role)
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]
def init_app(app, extra_config_settings={}): # Read common settings from 'app/settings.py' app.config.from_object('app.settings') # Read environment-specific settings from 'app/local_settings.py' try: app.config.from_object('app.local_settings') except ImportError: print("The configuration file 'app/local_settings.py' does not exist.\n"+ "Please copy app/local_settings_example.py to app/local_settings.py\n"+ "and customize its settings before you continue.") exit() # Add/overwrite extra settings from parameter 'extra_config_settings' app.config.update(extra_config_settings) if app.testing: app.config['WTF_CSRF_ENABLED'] = False # Disable CSRF checks while testing # Initialize Flask-SQLAlchemy and Flask-Script _after_ app.config has been read #db.init_app(app) # Setup Flask-Migrate #migrate = Migrate(app, db) #manager.add_command('db', MigrateCommand) # Setup Flask-Mail mail = Mail(app) # Setup WTForms CsrfProtect #CsrfProtect(app) # Define bootstrap_is_hidden_field for flask-bootstrap's bootstrap_wtf.html from wtforms.fields import HiddenField def is_hidden_field_filter(field): return isinstance(field, HiddenField) app.jinja_env.globals['bootstrap_is_hidden_field'] = is_hidden_field_filter # Setup an error-logger to send emails to app.config.ADMINS init_email_error_handler(app) # Setup Flask-User to handle user account related forms #from app.models import User, MyRegisterForm #from app.views import user_profile_page #db_adapter = SQLAlchemyAdapter(db, User) # Setup the SQLAlchemy DB Adapter #user_manager = UserManager(db_adapter, app, # Init Flask-User and bind to app #register_form=MyRegisterForm, # using a custom register form with UserProfile fields #user_profile_view_function=user_profile_page, #) #import app.manage_commands