Python wtforms 模块,HiddenField() 实例源码

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

项目:pillar    作者:armadillica    | 项目源码 | 文件源码
def get_node_form(node_type):
    """Get a procedurally generated WTForm, based on the dyn_schema and
    node_schema of a specific node_type.
    :type node_type: dict
    :param node_type: Describes the node type via dyn_schema, form_schema and
    parent
    """
    class ProceduralForm(Form):
        pass

    parent_prop = node_type['parent']

    ProceduralForm.name = StringField('Name', validators=[DataRequired()])
    # Parenting
    if parent_prop:
        parent_names = ", ".join(parent_prop)
        ProceduralForm.parent = HiddenField('Parent ({0})'.format(parent_names))

    ProceduralForm.description = TextAreaField('Description')
    ProceduralForm.picture = FileSelectField('Picture', file_format='image')
    ProceduralForm.node_type = HiddenField(default=node_type['name'])

    add_form_properties(ProceduralForm, node_type)

    return ProceduralForm()