How to use the wtforms.HiddenField function in WTForms

To help you get started, we’ve selected a few WTForms examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github lepture / flask-wtf / tests / base.py View on Github external
return text.decode('utf-8')
    return text


class MyForm(FlaskForm):
    SECRET_KEY = "a poorly kept secret."
    name = StringField("Name", validators=[DataRequired()])
    submit = SubmitField("Submit")


class HiddenFieldsForm(FlaskForm):
    SECRET_KEY = "a poorly kept secret."
    name = HiddenField()
    url = HiddenField()
    method = HiddenField()
    secret = HiddenField()
    submit = SubmitField("Submit")

    def __init__(self, *args, **kwargs):
        super(HiddenFieldsForm, self).__init__(*args, **kwargs)
        self.method.name = '_method'


class SimpleForm(FlaskForm):
    SECRET_KEY = "a poorly kept secret."
    pass


class CaptureHandler(logging.Handler):
    def __init__(self):
        self.records = []
        logging.Handler.__init__(self, logging.DEBUG)
github gateway4labs / labmanager / labmanager / views / embed.py View on Github external
name = TextField(lazy_gettext("Name:"), validators=[required()], widget = AngularJSTextInput(ng_model='embed.name', ng_enter="submitForm()"), description=lazy_gettext("Name of the resource"))
    age_ranges_range = HiddenField(lazy_gettext("Age ranges:"), validators=[], description=lazy_gettext("Select the age ranges this tool is useful for"))

    # The following are NOT REQUIRED
    description = TextField(lazy_gettext("Description:"), validators=[], widget = AngularJSTextInput(ng_model='embed.description', ng_enter="submitForm()"), description=lazy_gettext("Describe the resource in a few words"))
    domains_text = TextField(lazy_gettext("Domains:"), validators=[], widget = AngularJSTextInput(ng_enter="submitForm()"), description=lazy_gettext("Say in which domains apply to the resource (separated by commas): e.g., physics, electronics..."))

    url = URLField(lazy_gettext("Web:"), widget = AngularJSURLInput(ng_model='embed.url', ng_enter="submitForm()"), description=lazy_gettext("Web address of the resource"))
    height = HiddenField(lazy_gettext("Height:"), widget = AngularJSHiddenInput(ng_model='embed.height'))
    scale = HiddenField(lazy_gettext("Scale:"), widget = AngularJSHiddenInput(ng_model='embed.scale'))


class ApplicationForm(SimplifiedApplicationForm):
    url = URLField(lazy_gettext("Web:"), validators=[required()], widget = AngularJSURLInput(ng_model='embed.url', ng_enter="submitForm()"), description=lazy_gettext("Web address of the resource"))
    height = HiddenField(lazy_gettext("Height:"), validators=[required()], widget = AngularJSHiddenInput(ng_model='embed.height'))
    scale = HiddenField(lazy_gettext("Scale:"), validators=[required()], widget = AngularJSHiddenInput(ng_model='embed.scale'))
    uses_proxy = BooleanField(lazy_gettext("Try https proxy?"))

def obtain_formatted_languages(existing_language_codes):
    languages = [ (lang.split('_')[0], name) for lang, name in obtain_languages().items() if lang != 'en_ALL' and name != 'DEFAULT']

    return [ { 'code' : language, 'name' : name } for language, name in languages if language not in existing_language_codes]

def list_of_languages():
    return { key.split('_')[0] : value for key, value in obtain_languages().items() }
        
def _get_scale_value(form):
    if form.scale.data:
        try:
            scale = int(100 * float(form.scale.data))
        except ValueError:
            pass
github cd34 / apex / apex / forms.py View on Github external
return user

    def save(self, auth_id):
        new_user = self.create_user(auth_id, self.data['login'])
        self.after_signup(user=new_user)

    def after_signup(self, **kwargs):
        """ Function to be overloaded and called after form submission
        to allow you the ability to save additional form data or perform
        extra actions after the form submission.
        """
        pass

class OAuthForm(ExtendedForm):
    end_point = HiddenField('')
    csrf_token = HiddenField('')

class OpenIdLogin(OAuthForm):
    provider_name = 'openid'
    provider_proper_name = 'OpenID'

    openid_identifier = TextField(_('OpenID Identifier'), \
                                  [validators.Required()])

class GoogleLogin(OAuthForm):
    provider_name = 'google'
    provider_proper_name = 'Google'

class FacebookLogin(OAuthForm):
    provider_name = 'facebook'
    provider_proper_name = 'Facebook'
github Pagure / pagure / pagure / forms.py View on Github external
if 'status' in kwargs:
            self.status.choices = [
                (status, status) for status in kwargs['status']
            ]

        self.priority.choices = []
        if 'priorities' in kwargs:
            for key in sorted(kwargs['priorities']):
                self.priority.choices.append(
                    (key, kwargs['priorities'][key])
                )


class AddPullRequestCommentForm(wtf.Form):
    ''' Form to add a comment to a pull-request. '''
    commit = wtforms.HiddenField('commit identifier')
    filename = wtforms.HiddenField('file changed')
    row = wtforms.HiddenField('row')
    requestid = wtforms.HiddenField('requestid')
    tree_id = wtforms.HiddenField('treeid')
    comment = wtforms.TextAreaField(
        'Comment<span class="error">*</span>',
        [wtforms.validators.Required()]
    )


class AddPullRequestFlagForm(wtf.Form):
    ''' Form to add a flag to a pull-request. '''
    username = wtforms.TextField(
        'Username', [wtforms.validators.Required()])
    percent = wtforms.TextField(
        'Percentage of completion', [wtforms.validators.Required()])
github eucalyptus / eucaconsole / eucaconsole / forms / instances.py View on Github external
"""Instance form (to update an existing instance)
       Form to launch an instance is in LaunchInstanceForm
       Note: no need to add a 'tags' field.  Use the tag_editor panel (in a template) instead
    """
    name_error_msg = _(u'Not a valid name')
    name = TextEscapedField(label=_(u'Name'))
    instance_type_error_msg = _(u'Instance type is required')
    instance_type = wtforms.SelectField(label=_(u'Instance type'))
    userdata = wtforms.TextAreaField(label=_(u'User data'))
    userdata_file_helptext = _(u'User data file may not exceed 16 KB')
    userdata_file = wtforms.FileField(label='')
    ip_address = wtforms.SelectField(label=_(u'Public IP address'))
    monitored = wtforms.BooleanField(label=_(u'Monitoring enabled'))
    kernel = wtforms.SelectField(label=_(u'Kernel ID'))
    ramdisk = wtforms.SelectField(label=_(u'RAM disk ID (ramfs)'))
    start_later = wtforms.HiddenField()

    def __init__(self, request, instance=None, conn=None, **kwargs):
        super(InstanceForm, self).__init__(request, **kwargs)
        self.cloud_type = request.session.get('cloud_type', 'euca')
        self.instance = instance
        self.conn = conn
        self.name.error_msg = self.name_error_msg
        self.instance_type.error_msg = self.instance_type_error_msg
        self.choices_manager = ChoicesManager(conn=self.conn)
        self.set_choices()
        self.userdata_file.help_text = self.userdata_file_helptext

        if instance is not None:
            self.name.data = instance.tags.get('Name', '')
            self.instance_type.data = instance.instance_type
            self.ip_address.data = instance.ip_address or 'none'
github bslatkin / dpxdt / dpxdt / server / forms.py View on Github external
"""Form for viewing or approving a release."""

    id = HiddenField(validators=[NumberRange(min=1)])
    name = HiddenField(validators=[Length(min=1, max=200)])
    number = HiddenField(validators=[NumberRange(min=1)])

    good = HiddenField()
    bad = HiddenField()
    reviewing = HiddenField()


class RunForm(Form):
    """Form for viewing or approving a run."""

    id = HiddenField(validators=[NumberRange(min=1)])
    name = HiddenField(validators=[Length(min=1, max=200)])
    number = HiddenField(validators=[NumberRange(min=1)])
    test = HiddenField(validators=[Length(min=1, max=200)])
    type = HiddenField(validators=[Length(min=1, max=200)])
    approve = HiddenField()
    disapprove = HiddenField()


class CreateApiKeyForm(Form):
    """Form for creating an API key."""

    build_id = HiddenField(validators=[NumberRange(min=1)])
    purpose = TextField('Purpose', validators=[Length(min=1, max=200)])
    create = SubmitField('Create')


class RevokeApiKeyForm(Form):
github fedora-infra / fas / fas / forms / people.py View on Github external
check_availibility(key='username'),
            check_blacklist()])


class EmailForm(Form):
    """ Form to validate email. """
    email = StringField(
        _(u'Email'),
        [validators.Required(),
            validators.Email(),
            check_availibility(key='email')])


class ContactInfosForm(EmailForm):
    """ Form to edit contact infos. """
    username = HiddenField()
    fullname = StringField(_(u'Full name'), [validators.Required()])
    facsimile = StringField(_(u'Facsimile'))
    telephone = StringField(_(u'Telephone number'))
    postal_address = StringField(_(u'Postal address'), [validators.Optional()])
    affiliation = StringField(_(u'Affiliation'), [validators.Optional()])
    country_code = SelectField(
        _(u'Country code'),
        [validators.Required()],
        coerce=str,
        choices=[(-1, _(u'-- None --'))])


class ResetPasswordPeopleForm(Form):
    """ Form to used to reset one's password. """
    new_password = PasswordField(
        _(u'New Password'),
github shn7798 / FlaskZhihu / FlaskZhihu / forms / comment.py View on Github external
# -*- coding: utf-8 -*-
__author__ = 'shn7798'

from flask.ext.wtf import Form
from wtforms import TextAreaField, SubmitField, HiddenField
from wtforms.validators import required, Regexp

__all__ = ['CommentAddForm']


class CommentAddForm(Form):
    target_type = HiddenField(validators=[required(message=u'请输入评论类型'),
                                          Regexp(r'^[a-z]+$')])
    target_id = HiddenField(validators=[required(message=u'请输入评论所属ID'),
                                        Regexp(r'^\d+$')])
    content = TextAreaField(validators=[required(message=u'请输入内容')])
github csm-aut / csm / csmserver / views / asr9k_x64_migrate.py View on Github external
scheduled_time = StringField('Scheduled Time', [required()])
    scheduled_time_UTC = HiddenField('Scheduled Time')
    custom_command_profile = SelectMultipleField('Custom Command Profile', coerce=int, choices=[(-1, '')])

    region = SelectField('Region', coerce=int, choices=[(-1, '')])
    role = SelectField('Role', coerce=str, choices=[('Any', 'Any')])
    software = SelectField('Software Version', coerce=str, choices=[('Any', 'Any')])

    server_dialog_target_software = StringField('Target Software Release')
    server_dialog_server = SelectField('Server Repository', coerce=int, choices=[(-1, '')])
    server_dialog_server_directory = SelectField('Server Directory', coerce=str, choices=[('', '')])

    hidden_region = HiddenField('')
    hidden_hosts = HiddenField('')

    hidden_server = HiddenField('')
    hidden_server_name = HiddenField('')
    hidden_server_directory = HiddenField('')
    hidden_pending_downloads = HiddenField('Pending Downloads')
    hidden_software_packages = HiddenField('')

    hidden_override_hw_req = HiddenField('')
    hidden_config_filename = HiddenField('')

    hidden_edit = HiddenField('Edit')

    hidden_dependency = HiddenField('')

    hardware_audit_version = StringField('ASR9K-X64 Software Version')
    hidden_hardware_audit_version = HiddenField('')
github wilfriedE / LearnIt / main / control / lesson.py View on Github external
html_class='lesson-card',
    )

###############################################################################
# New Lesson
###############################################################################
class NewLessonForm(wtf.Form):
  name = wtforms.StringField(
      'Name',
      [wtforms.validators.required()], filters=[util.strip_filter],
    )
  topics = wtforms.StringField('Topics')
  description = wtforms.TextAreaField(
      'Description', [wtforms.validators.Length(min=2, max=400)],
    )
  lesson_id = wtforms.HiddenField() #This field is only nesessary when creating a new version of an existing lesson.
  is_a = wtforms.StringField('Content Type', [wtforms.validators.required()])

@app.route('/lesson/create')
@auth.login_required
def new_lesson():
  """Renders the new lesson creation page"""
  form = NewLessonForm()
  return flask.render_template(
      'lesson/lesson_update.html',
      title='New Lesson',
      post_path=flask.url_for('api.lesson.new'),
      form=form,
      html_class='lesson',
    )

##This would be the process where users can propose new versions for a Lesson. These would of course need approval.